From 88e03cf57e352f862b15c5da3d11e3fb6db333ef Mon Sep 17 00:00:00 2001 From: amirrr <6696894+amirrr@users.noreply.github.com> Date: Sat, 13 Jul 2024 21:10:20 +0200 Subject: [PATCH] feat: Serve static files from the build directory This commit modifies the server's API file to serve static files from the "build" directory. This change adds the line `app.static("/", "./build")` to the code. Recent user commits: - add working assistant - fixing - linting fix + requirement change - Refactor server initialization to use app.before_server_start decorator - feat: Disable comet animation on Galaxy login page - add working login - database - feat: Add Galaxy login page with background animation and email submission form Recent repository commits: - add working assistant - fixing - linting fix + requirement change - Refactor server initialization to use app.before_server_start decorator - feat: Disable comet animation on Galaxy login page - add working login - database - feat: Add Galaxy login page with background animation and email submission form - Update README.md --- server/api.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/api.py b/server/api.py index 16ad9af..aafc45f 100644 --- a/server/api.py +++ b/server/api.py @@ -14,6 +14,8 @@ app = Sanic("Atlas", config=AppConfig()) +app.static("/", "./build") + # Initialize CORS CORS(app, resources={r"/*": {"origins": "*"}}) @@ -89,11 +91,10 @@ def handle_message(data): # Regular routes @app.route("/") -async def index(_request: Request): - """Serves the index.html file.""" - return await response.file( - os.path.join(app.config.FALLBACK_STATIC_DIR, "index.html") - ) +@app.route("/") +async def route(req, param=None): + """""" + return response.text(param if param else "homepage") @app.exception(404)