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
All checks were successful
Build and Push Madplaner / build (push) Successful in 25s
This commit is contained in:
19
app.py
19
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, 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():
|
||||
|
||||
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
@@ -13,6 +13,15 @@
|
||||
<!-- cache busting for serivce worker -->
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}?v=1.1">
|
||||
</head>
|
||||
|
||||
<script
|
||||
defer
|
||||
src="/stats/script.js"
|
||||
data-website-id="4909e1da-6d66-4035-a401-f2acbaebdd3b"
|
||||
data-host-url="/stats">
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('/sw.js')
|
||||
|
||||
Reference in New Issue
Block a user