|
53 | 53 | event = None
|
54 | 54 | conv = None
|
55 | 55 |
|
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 |
62 | 57 |
|
| 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/') |
63 | 61 |
|
64 |
| -# Connexion wraps FlaskApp, so app becomes app |
| 62 | +# Connexion wraps FlaskApp, so app becomes connexionApp.app |
65 | 63 | app = connexionApp.app
|
66 |
| -CORS(app) # Access-Control-Allow-Origin |
| 64 | +# Access-Control-Allow-Origin |
| 65 | +CORS(app) |
67 | 66 | babel = Babel(app)
|
68 | 67 | app.debug = False
|
69 | 68 | app.prog_engine = ProgramEngine.get_instance()
|
70 | 69 | app.prog = None
|
71 | 70 | app.shutdown_requested = False
|
72 | 71 |
|
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({})) |
74 | 100 |
|
75 | 101 | @babel.localeselector
|
76 | 102 | def get_locale():
|
@@ -106,28 +132,6 @@ def render_static_assets3(filename):
|
106 | 132 | def render_static_assets4(filename):
|
107 | 133 | return send_from_directory('static/media', filename)
|
108 | 134 |
|
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 |
| - |
131 | 135 | """
|
132 | 136 | Update the keys of oldDict appearing in updatedValues with the values in
|
133 | 137 | updatedValues
|
|
0 commit comments