Private
Public Access
1
0

Merge pull request 'umami site analytics' (#1) from umami into main
All checks were successful
Build and Push Madplaner / build (push) Successful in 39s

Reviewed-on: #1
This commit is contained in:
2025-12-30 20:13:46 +01:00
3 changed files with 26 additions and 2 deletions

17
app.py
View File

@@ -1,6 +1,7 @@
import os import os
import requests
from dotenv import load_dotenv 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_sqlalchemy import SQLAlchemy
from flask_login import ( from flask_login import (
LoginManager, LoginManager,
@@ -58,7 +59,21 @@ class MealPlan(db.Model):
def load_user(user_id): def load_user(user_id):
return User.query.get(int(user_id)) return User.query.get(int(user_id))
UMAMI_LOCAL_URL = "http://192.168.0.37:3007"
@app.route('/stats/<path:path>', 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("/") @app.route("/")
def index(): def index():

Binary file not shown.

View File

@@ -7,6 +7,15 @@
<script src="https://cdn.tailwindcss.com"></script> <script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
</head> </head>
<script
defer
src="/stats/script.js"
data-website-id="4909e1da-6d66-4035-a401-f2acbaebdd3b"
data-host-url="/stats">
</script>
<body class="bg-gray-50 text-gray-900 font-sans"> <body class="bg-gray-50 text-gray-900 font-sans">
{% with messages = get_flashed_messages(with_categories=true) %} {% with messages = get_flashed_messages(with_categories=true) %}