Private
Public Access
1
0

Merge branch 'main' of http://192.168.0.37:3000/rasmus/madplaner
All checks were successful
Build and Push Madplaner / build (push) Successful in 25s

This commit is contained in:
2025-12-30 21:20:59 +01:00
3 changed files with 26 additions and 2 deletions

19
app.py
View File

@@ -1,6 +1,7 @@
import os
import requests
from dotenv import load_dotenv
from flask import Flask, render_template, redirect, url_for, request, flash, send_from_directory
from flask import Flask, render_template, redirect, url_for, request, flash, Response, send_from_directory
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))
# PWA service worker
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)# PWA service worker
@app.route('/sw.js')
def serve_sw():