diff --git a/app.py b/app.py index 21567e5..76b8ce4 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,7 @@ import os +import requests from dotenv import load_dotenv -from flask import Flask, render_template, redirect, url_for, request, flash +from flask import Flask, render_template, redirect, url_for, request, flash, Response from flask_sqlalchemy import SQLAlchemy from flask_login import ( LoginManager, @@ -58,7 +59,21 @@ class MealPlan(db.Model): def load_user(user_id): return User.query.get(int(user_id)) - +UMAMI_LOCAL_URL = "http://192.168.0.37:3007" +@app.route('/stats/', methods=['GET', 'POST']) +def umami_proxy(path): + url = f"{UMAMI_LOCAL_URL}/{path}" + + # Forward the request to Umami (including headers and data) + if request.method == 'POST': + resp = requests.post(url, json=request.json, headers=request.headers) + else: + resp = requests.get(url, params=request.args, headers=request.headers) + # Clean up headers to avoid encoding issues + excluded_headers = ['content-encoding', 'content-length', 'transfer-encoding', 'connection'] + headers = [(name, value) for (name, value) in resp.raw.headers.items() + if name.lower() not in excluded_headers] + return Response(resp.content, resp.status_code, headers) @app.route("/") def index(): diff --git a/requirements.txt b/requirements.txt index b5acd55..4c6a5e1 100644 Binary files a/requirements.txt and b/requirements.txt differ diff --git a/templates/base.html b/templates/base.html index 68444ad..6276703 100644 --- a/templates/base.html +++ b/templates/base.html @@ -7,6 +7,15 @@ + + + + {% with messages = get_flashed_messages(with_categories=true) %}