Skip to content

Commit 27e1818

Browse files
committed
/2 -> /old for serving the old web app. Comments, improvements
1 parent 73b56d3 commit 27e1818

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

main.py

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,50 @@
5353
event = None
5454
conv = None
5555

56-
# (Connexion) Flask app configuration
57-
connexionApp = connexion.App(__name__, swagger_ui=True, swagger_path='swagger-ui/')
58-
# We serve a custom version of the swagger ui (Jinja2 templates) based on the default one
59-
60-
# New API is defined in v2.yml and its methods are in api.py
61-
connexionApp.add_api('v2.yml')
56+
## (Connexion) Flask app configuration
6257

58+
# Serve a custom version of the swagger ui (Jinja2 templates) based on the default one
59+
# from the folder 'swagger-ui'. Clone the 'swagger-ui' repository inside the backend folder
60+
connexionApp = connexion.App(__name__, swagger_ui=True, swagger_path='swagger-ui/')
6361

64-
# Connexion wraps FlaskApp, so app becomes app
62+
# Connexion wraps FlaskApp, so app becomes connexionApp.app
6563
app = connexionApp.app
66-
CORS(app) # Access-Control-Allow-Origin
64+
# Access-Control-Allow-Origin
65+
CORS(app)
6766
babel = Babel(app)
6867
app.debug = False
6968
app.prog_engine = ProgramEngine.get_instance()
7069
app.prog = None
7170
app.shutdown_requested = False
7271

73-
## Legacy Routes
72+
## New API and web application
73+
74+
# API v2 is defined in v2.yml and its methods are in api.py
75+
connexionApp.add_api('v2.yml')
76+
77+
# Serve (a build of) the new Vue application
78+
# "dist" is the output of `npm run build` from the 'vue-app 'repository
79+
80+
@app.route('/vue/<path:filename>')
81+
def serve_vue_app(filename):
82+
return send_from_directory('dist', filename)
83+
84+
@app.route('/')
85+
def redirect_vue_app():
86+
return redirect('/vue/index.html', code=302)
87+
88+
## Legacy API and web application
89+
90+
# Serve the legacy web application templates
91+
@app.route("/old")
92+
def handle_home():
93+
return render_template('main.html',
94+
host=request.host[:request.host.find(':')],
95+
locale=get_locale(),
96+
config=app.bot_config,
97+
program_level=app.bot_config.get("prog_level", "std"),
98+
cam=cam != None,
99+
cnn_model_names = json.dumps({}))
74100

75101
@babel.localeselector
76102
def get_locale():
@@ -106,28 +132,6 @@ def render_static_assets3(filename):
106132
def render_static_assets4(filename):
107133
return send_from_directory('static/media', filename)
108134

109-
# Serve the new Vue application (build)
110-
# "dist" is the output of `npm run build` from the vue-app repository
111-
112-
@app.route('/vue/<path:filename>')
113-
def render_static_assets5(filename):
114-
return send_from_directory('dist', filename)
115-
116-
@app.route('/')
117-
def render_static_assets6():
118-
return redirect('/vue/index.html', code=302)
119-
120-
# Serve web app application templates
121-
@app.route("/2")
122-
def handle_home():
123-
return render_template('main.html',
124-
host=request.host[:request.host.find(':')],
125-
locale=get_locale(),
126-
config=app.bot_config,
127-
program_level=app.bot_config.get("prog_level", "std"),
128-
cam=cam != None,
129-
cnn_model_names = json.dumps({}))
130-
131135
"""
132136
Update the keys of oldDict appearing in updatedValues with the values in
133137
updatedValues

0 commit comments

Comments
 (0)