|
1 | 1 | import os |
| 2 | +import re |
2 | 3 |
|
3 | 4 | import sentry_sdk |
4 | | -from flask import Flask, jsonify, make_response, send_from_directory, redirect |
| 5 | +from flask import Flask, jsonify, make_response, send_from_directory |
5 | 6 | from flask_cors import CORS |
6 | 7 | from sentry_sdk.integrations.flask import FlaskIntegration |
7 | 8 | from werkzeug.middleware.proxy_fix import ProxyFix |
|
22 | 23 | from .manage import add_question, del_question # NoQA |
23 | 24 | from .models import db, init_db # NoQA |
24 | 25 |
|
| 26 | +STATIC_FILES = re.compile(r"\.(ico|png|xml|json)$") |
25 | 27 |
|
26 | 28 | # Globally accessible libraries |
27 | 29 |
|
@@ -93,24 +95,12 @@ def send_images(path): |
93 | 95 | def send_assets(path): |
94 | 96 | return send_from_directory("assets", path) |
95 | 97 |
|
96 | | - @app.route("/landing", defaults={"path": ""}) |
97 | | - @app.route("/landing/<path:path>") |
98 | | - def send_landing(path): |
99 | | - |
100 | | - # if core.current_rank() != -1: |
101 | | - # return redirect("/") |
102 | | - |
103 | | - if path: |
104 | | - return send_from_directory("../landing/", path) |
105 | | - return send_from_directory("../landing/", "index.html") |
106 | | - |
107 | 98 | @app.route("/", defaults={"path": ""}) |
108 | 99 | @app.route("/<path:path>") |
109 | 100 | def catch_all(path): |
110 | 101 |
|
111 | | - # show landing page |
112 | | - if core.current_rank() == -1 and (not path or path == "home"): |
113 | | - return redirect("/landing") |
| 102 | + if STATIC_FILES.search(path): |
| 103 | + return send_from_directory(app.config["DIST_DIR"], path) |
114 | 104 |
|
115 | 105 | return send_from_directory(app.config["DIST_DIR"], "index.html") |
116 | 106 |
|
|
0 commit comments