Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions CodeChallenge/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import re

import sentry_sdk
from flask import Flask, jsonify, make_response, send_from_directory, redirect
from flask import Flask, jsonify, make_response, send_from_directory
from flask_cors import CORS
from sentry_sdk.integrations.flask import FlaskIntegration
from werkzeug.middleware.proxy_fix import ProxyFix
Expand All @@ -22,6 +23,7 @@
from .manage import add_question, del_question # NoQA
from .models import db, init_db # NoQA

STATIC_FILES = re.compile(r"\.(ico|png|xml|json)$")

# Globally accessible libraries

Expand Down Expand Up @@ -93,24 +95,12 @@ def send_images(path):
def send_assets(path):
return send_from_directory("assets", path)

@app.route("/landing", defaults={"path": ""})
@app.route("/landing/<path:path>")
def send_landing(path):

# if core.current_rank() != -1:
# return redirect("/")

if path:
return send_from_directory("../landing/", path)
return send_from_directory("../landing/", "index.html")

@app.route("/", defaults={"path": ""})
@app.route("/<path:path>")
def catch_all(path):

# show landing page
if core.current_rank() == -1 and (not path or path == "home"):
return redirect("/landing")
if STATIC_FILES.search(path):
return send_from_directory(app.config["DIST_DIR"], path)

return send_from_directory(app.config["DIST_DIR"], "index.html")

Expand Down
2 changes: 1 addition & 1 deletion CodeChallenge/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ class DevelopmentConfig(ProductionConfig):

@property
def DIST_DIR(self):
return os.path.join(self.ROOT_DIR, "public")
return os.path.join(self.ROOT_DIR, "dist")