diff --git a/app.py b/app.py
index 66024de..3d6daa3 100644
--- a/app.py
+++ b/app.py
@@ -12,6 +12,9 @@ import traceback
# Load environment variables from .env file
load_dotenv()
+# Base URL configuration from environment variable, default to empty string if not set
+BASE_URL = os.getenv("BASE_URL", "")
+
app = Flask(__name__)
# Database configuration from environment variables
@@ -200,7 +203,7 @@ def analyze_data(df, part_info_df):
@app.route('/')
def index():
"""Render the main monitoring dashboard"""
- return render_template('index.html')
+ return render_template('index.html', base_url=BASE_URL)
def fetch_part_history(part_id, days=14):
"""Fetch historical data for a specific part_id for the last 'days' days"""
diff --git a/static/js/script.js b/static/js/script.js
index 6148a45..2cfe126 100644
--- a/static/js/script.js
+++ b/static/js/script.js
@@ -88,7 +88,7 @@ function fetchData(date) {
errorMessage.classList.add('d-none');
// Build the URL with date parameter if provided
- let url = '/api/data';
+ let url = BASE_URL + '/api/data';
if (date) {
url += `?date=${encodeURIComponent(date)}`;
}
@@ -315,7 +315,7 @@ function updateStatusCounts(redCount, yellowCount) {
* Fetch historical data for a specific part_id
*/
function fetchPartHistory(partId) {
- return fetch(`/api/part-history?part_id=${encodeURIComponent(partId)}`)
+ return fetch(`${BASE_URL}/api/part-history?part_id=${encodeURIComponent(partId)}`)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
diff --git a/templates/index.html b/templates/index.html
index 8814f6d..2e4e8af 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -138,6 +138,10 @@
+