-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathapp.py
More file actions
50 lines (40 loc) · 1.2 KB
/
app.py
File metadata and controls
50 lines (40 loc) · 1.2 KB
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
from flask import Flask, render_template, redirect, jsonify, current_app
from flask_cors import CORS
from views.job_composer import job_composer
from views import socket_handler
from views.utils import get_drona_dir, get_drona_root
import yaml
import os
app = Flask(__name__)
def detect_env():
path = os.getcwd()
if "dev" in path:
return "development"
elif "sys" in path:
return "production"
else:
return "unknown"
CORS(app)
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.config['drona_root'] = get_drona_root()
dd = get_drona_dir()
if dd["ok"]:
app.config['drona_dir'] = dd["drona_dir"]
else:
app.config["drona_dir"] = None
app.register_blueprint(job_composer, url_prefix="/jobs/composer")
@app.route("/")
def index():
return render_template("index.html")
@app.route("/config")
def config_route():
return detect_env()
if __name__ == "__main__":
app.run(debug=True)