liqian пре 3 година
родитељ
комит
9747af2c3a
3 измењених фајлова са 16 додато и 6 уклоњено
  1. 2 0
      .gitignore
  2. 3 2
      app.py
  3. 11 4
      config.py

+ 2 - 0
.gitignore

@@ -60,3 +60,5 @@ target/
 
 .idea/
 
+env.conf
+

+ 3 - 2
app.py

@@ -1,3 +1,6 @@
+from gevent import monkey
+monkey.patch_all()
+
 import json
 import time
 
@@ -14,9 +17,7 @@ from gevent.pywsgi import WSGIServer
 from multiprocessing import cpu_count, Process
 from utils import update_video_w_h_rate
 # from werkzeug.middleware.profiler import ProfilerMiddleware
-from gevent import monkey
 
-monkey.patch_all()
 
 app = Flask(__name__)
 #app.wsgi_app = ProfilerMiddleware(app.wsgi_app)

+ 11 - 4
config.py

@@ -256,7 +256,14 @@ class ProductionConfig(BaseConfig):
 
 
 def set_config():
-    # return DevelopmentConfig()
-    # return TestConfig()
-    # return PreProductionConfig()
-    return ProductionConfig()
+    with open('env.conf', 'r') as env_f:
+        line = env_f.read()
+        env = line.split('=')[1].strip()
+    if env == 'dev':
+        return DevelopmentConfig()
+    elif env == 'test':
+        return TestConfig()
+    elif env == 'pre':
+        return PreProductionConfig()
+    elif env == 'pro':
+        return ProductionConfig()