-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathrun.py
39 lines (30 loc) · 1.02 KB
/
run.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
# -*- encoding: utf-8 -*-
"""
Copyright (c) 2019 - present AppSeed.us
"""
import os
import random
import string
#from flask_migrate import Migrate
from flask_minify import Minify
from sys import exit
from apps.config import config_dict
from apps import create_app, db
from flask import session
# WARNING: Don't run with debug turned on in production!
DEBUG = os.getenv('DEBUG', 'False')
# The configuration
get_config_mode = 'Production'
try:
# Load the configuration using the default values
app_config = config_dict[get_config_mode.capitalize()]
except KeyError:
exit('Error: Invalid <config_mode>. Expected values [Debug, Production] ')
app = create_app(app_config)
if not os.getenv('SECRET_KEY'):
os.environ['SECRET_KEY']=''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(31))
print(" * Env var SECRET_KEY is not set. Using a random key")
app.secret_key = os.getenv('SECRET_KEY')
Minify(app=app, html=True, js=False, cssless=False)
if __name__ == "__main__":
app.run()