Fix debug mode in production
This commit is contained in:
@@ -12,9 +12,15 @@ db.connect()
|
|||||||
conf = KeyValueStorage(db)
|
conf = KeyValueStorage(db)
|
||||||
firewall = ProxyManager(db)
|
firewall = ProxyManager(db)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import uwsgi
|
||||||
|
IN_UWSGI = True
|
||||||
|
except ImportError:
|
||||||
|
IN_UWSGI = False
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
DEBUG = not (len(sys.argv) > 1 and sys.argv[1] == "UWSGI")
|
DEBUG = not ((len(sys.argv) > 1 and sys.argv[1] == "UWSGI") or IN_UWSGI)
|
||||||
|
|
||||||
def is_loggined():
|
def is_loggined():
|
||||||
if DEBUG: return True
|
if DEBUG: return True
|
||||||
@@ -44,6 +50,13 @@ def before_first_request():
|
|||||||
|
|
||||||
@app.route("/api/status")
|
@app.route("/api/status")
|
||||||
def get_status():
|
def get_status():
|
||||||
|
if DEBUG:
|
||||||
|
return {
|
||||||
|
"status":app.config["STATUS"],
|
||||||
|
"loggined": is_loggined(),
|
||||||
|
"debug":True
|
||||||
|
}
|
||||||
|
else:
|
||||||
return {
|
return {
|
||||||
"status":app.config["STATUS"],
|
"status":app.config["STATUS"],
|
||||||
"loggined": is_loggined()
|
"loggined": is_loggined()
|
||||||
|
|||||||
Reference in New Issue
Block a user