diff --git a/src/app.py b/src/app.py
index c34715d..43b49b6 100644
--- a/src/app.py
+++ b/src/app.py
@@ -2,7 +2,15 @@
from dash import Dash, html, dcc
import dash_bootstrap_components as dbc
-from flask import jsonify, redirect, render_template_string, request, session, url_for
+from flask import (
+ jsonify,
+ redirect,
+ render_template_string,
+ request,
+ send_from_directory,
+ session,
+ url_for,
+)
import hashlib
import logging
import plotly.express as px
@@ -48,15 +56,19 @@
)
-@app.route("/")
-def home():
- return render_template_string(
- """
-
Welcome to the Flask + Dash Web App
- This page is served by Flask.
- Click here to go to the Dash app.
- """
- )
+# @app.route("/")
+# def home():
+# return render_template_string(
+# """
+# Welcome to the Flask + Dash Web App
+# This page is served by Flask.
+# Click here to go to the Dash app.
+# """
+# )
+@app.route("/", defaults={"path": ""})
+@app.route("/")
+def serve_react_app(path):
+ return send_from_directory(app.static_folder, "index.html")
@app.route("/login", methods=["GET", "POST"])
diff --git a/src/common.py b/src/common.py
index 36bfec3..b265620 100644
--- a/src/common.py
+++ b/src/common.py
@@ -1,3 +1,4 @@
+import os
from flask import Flask
from flask_cors import CORS
@@ -9,5 +10,12 @@
if app is None:
server_name = getenv("SERVER_NAME", "Semantic Search Engine")
print(f"Server Name: {server_name}")
- app = Flask(server_name)
+ public_path = os.path.realpath(os.path.join(os.path.dirname(__file__), "public"))
+ public_path = getenv("PUBLIC_PATH", public_path)
+ app = Flask(
+ server_name,
+ static_folder=public_path,
+ template_folder=public_path,
+ static_url_path="/",
+ )
CORS(app)
diff --git a/src/env.py b/src/env.py
index c5e910f..803ce0f 100644
--- a/src/env.py
+++ b/src/env.py
@@ -9,9 +9,8 @@ def getenv(name, default=None):
global env_loaded
if not env_loaded:
env_name = os.getenv("ENVIRONMENT", "")
- env_file = (
- f".env.{env_name}" if env_name else ".env"
- ) # Default to '.env' if not set
- load_dotenv(dotenv_path=env_file, verbose=True)
+ env_file_path = f".env.{env_name}" if env_name else ".env"
+ print(f'Loading environment variables from "{env_file_path}"')
+ load_dotenv(dotenv_path=env_file_path, verbose=True)
env_loaded = True
return os.getenv(name, default)