Beef up the Production check a little and do true comparison correctly.
This commit is contained in:
parent
2067875c6a
commit
18437003cf
4 changed files with 12 additions and 3 deletions
|
@ -12,6 +12,7 @@ services:
|
||||||
environment:
|
environment:
|
||||||
- DATABASE_URL=postgresql://postgres@postgres:5432
|
- DATABASE_URL=postgresql://postgres@postgres:5432
|
||||||
- REDIS_URL=redis://redis
|
- REDIS_URL=redis://redis
|
||||||
|
- ENFORCE_PRODUCTION=False
|
||||||
links:
|
links:
|
||||||
- "redis"
|
- "redis"
|
||||||
- "postgres"
|
- "postgres"
|
||||||
|
|
2
env
2
env
|
@ -2,7 +2,7 @@ MASTER_KEY=blahblahblah
|
||||||
DOMAIN=localhost
|
DOMAIN=localhost
|
||||||
SITE_ID=TheMotte
|
SITE_ID=TheMotte
|
||||||
SITE_TITLE=The Motte
|
SITE_TITLE=The Motte
|
||||||
ENFORCE_PRODUCTION=False
|
ENFORCE_PRODUCTION=True
|
||||||
GIPHY_KEY=blahblahblah
|
GIPHY_KEY=blahblahblah
|
||||||
DISCORD_SERVER_ID=blahblahblah
|
DISCORD_SERVER_ID=blahblahblah
|
||||||
DISCORD_CLIENT_ID=blahblahblah
|
DISCORD_CLIENT_ID=blahblahblah
|
||||||
|
|
|
@ -4,6 +4,7 @@ import gevent.monkey
|
||||||
gevent.monkey.patch_all()
|
gevent.monkey.patch_all()
|
||||||
from os import environ, path
|
from os import environ, path
|
||||||
import secrets
|
import secrets
|
||||||
|
from files.helpers.strings import bool_from_string
|
||||||
from flask import *
|
from flask import *
|
||||||
from flask_caching import Cache
|
from flask_caching import Cache
|
||||||
from flask_limiter import Limiter
|
from flask_limiter import Limiter
|
||||||
|
@ -27,7 +28,7 @@ app.jinja_env.cache = {}
|
||||||
app.jinja_env.auto_reload = True
|
app.jinja_env.auto_reload = True
|
||||||
faulthandler.enable()
|
faulthandler.enable()
|
||||||
|
|
||||||
if environ.get("ENFORCE_PRODUCTION", False) and app.config["DEBUG"]:
|
if bool_from_string(environ.get("ENFORCE_PRODUCTION", "true")) and app.config["DEBUG"]:
|
||||||
raise ValueError("Debug mode is not allowed! If this is a dev environment, please set ENFORCE_PRODUCTION to false")
|
raise ValueError("Debug mode is not allowed! If this is a dev environment, please set ENFORCE_PRODUCTION to false")
|
||||||
|
|
||||||
if environ.get("SITE_ID") is None:
|
if environ.get("SITE_ID") is None:
|
||||||
|
|
|
@ -2,3 +2,10 @@
|
||||||
# clean strings for searching
|
# clean strings for searching
|
||||||
def sql_ilike_clean(my_str):
|
def sql_ilike_clean(my_str):
|
||||||
return my_str.replace(r'\\', '').replace('_', r'\_').replace('%', '').strip()
|
return my_str.replace(r'\\', '').replace('_', r'\_').replace('%', '').strip()
|
||||||
|
|
||||||
|
def bool_from_string(str_in: str) -> bool:
|
||||||
|
if str_in.lower() in ("yes", "true", "t", "1"):
|
||||||
|
return True
|
||||||
|
if str_in.lower() in ("no", "false", "f", "0"):
|
||||||
|
return False
|
||||||
|
raise ValueError()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue