-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wsgi_dev.py
70 lines (50 loc) · 1.79 KB
/
wsgi_dev.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# -*- encoding: utf-8 -*-
"""
wsgi file to run app in production mode from gunicorn
"""
import os, sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ###
### ENV VARS
### + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ###
from dotenv import load_dotenv
from pathlib import Path # python3 only
env_path_global = Path('.') / 'example.env.global'
load_dotenv(env_path_global, verbose=True)
try :
env_path_superAdmins = Path('.') / '.env.superadmins'
load_dotenv(env_path_superAdmins, verbose=True)
except :
env_path_superAdmins = Path('.') / 'example.env.superadmins'
load_dotenv(env_path_superAdmins, verbose=True)
### READ ENV VARS
run=os.getenv('RUN_MODE', 'default')
docker=os.getenv('DOCKER_MODE', 'docker_off')
mongodb=os.getenv('MONGODB_MODE', 'local')
print ("= = = WSGI_DEV / run : ", run)
print ("= = = WSGI_DEV / docker : ", docker)
print ("= = = WSGI_DEV / mongodb : ", mongodb)
### READ ENV VARS DEPENDING ON MODE
# MONGODB - RELATED
if mongodb in ['local'] :
env_path_mongodb = Path('.') / 'example.env.mongodb'
else :
env_path_mongodb = Path('.') / '.env.mongodb'
load_dotenv(env_path_mongodb, verbose=True)
from backend import app, log_app
if __name__ == '__main__':
"""
runner for the CIS front Flask app
- warning : gets most of its variables at start from environment variables
in command line just type :
"python wsgi_dev.py"
or
"gunicorn --bind 0.0.0.0:8100 --workers=1 wsgi_dev:app" for instance
"""
# set environment variable to set config later in config_app.config_env.py
print ("= "*25)
print ("= = = WSGI / RERUN FLASK APP = = =")
log_app.info
print ("= "*25)
# simple flask runner
app.run()