-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
48 lines (36 loc) · 1.01 KB
/
app.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
from flask import Flask, render_template, redirect, jsonify
from flask_cors import CORS
from views.job_composer import job_composer
import yaml
import os
import sqlite3
import re
app = Flask(__name__)
def detect_env():
path = os.getcwd()
if "dev" in path:
return "development"
elif "sys" in path:
return "production"
else:
return "unknown"
# DEVELOPMENT
CORS(app)
# env = os.environ["RACK_ENV"]
env = detect_env()
def load_config(config_file='config.yml'):
with open(config_file, 'r') as file:
config_data = yaml.safe_load(file)
return config_data
config = load_config()['development'] if env == 'development' else load_config()['production']
app.config.update(config)
app.config['user'] = os.environ['USER']
app.register_blueprint(job_composer, url_prefix="/jobs/composer")
@app.route("/")
def index():
return render_template("index.html")
@app.route("/config")
def config():
return detect_env()
if __name__ == "__main__":
app.run(debug=True)