Private
Public Access
1
0

refactor css and test docker compose
All checks were successful
Redeploy landing on Push / Explore-Gitea-Actions (push) Successful in 7s

This commit is contained in:
2025-12-22 19:55:58 +01:00
parent c9c9610de9
commit bc9643a275
3 changed files with 123 additions and 138 deletions

21
app.py
View File

@@ -1,4 +1,4 @@
from flask import Flask, render_template, Response, stream_with_context, request
from flask import Flask, render_template, Response, request
from flask_flatpages import FlatPages
from werkzeug.middleware.proxy_fix import ProxyFix
import requests
@@ -23,20 +23,18 @@ def index():
@app.route('/about')
def about():
return render_template('about.html')
@app.route('/proxy-chat', methods=['POST'])
def proxy_chat():
target_url = "http://192.168.0.37:5002/v1/chat/completions"
try:
# 1. Forward the request without stream=True
# llama.cpp will now send back one large JSON object
response = requests.post(
target_url,
json=request.json,
timeout=120 # Important: Give the i5-8400 time to think
timeout=300 # Important: Give the server time to process. Set very long timeout
)
# 2. Return the full JSON response to the browser
return Response(
response.content,
status=response.status_code,
@@ -44,12 +42,12 @@ def proxy_chat():
)
except requests.exceptions.Timeout:
return {"error": "The serve took too long to answer. Try a different prompt."}, 504
return {"error": "The server took too long to answer. Try a different prompt."}, 504
except Exception as e:
return {"error": str(e)}, 500
@app.route('/post/<path:path>/') # Adding /post/ prefix helps organize URLs
@app.route('/post/<path:path>/')
def post(path):
page = pages.get_or_404(path)
return render_template('post.html', page=page)
@@ -59,14 +57,5 @@ def tag(tag_name):
tagged_pages = [p for p in pages if tag_name in p.meta.get('tags', [])]
return render_template('tag.html', pages=tagged_pages, tag_name=tag_name)
@app.context_processor
def inject_tags():
all_tags = set()
for page in pages:
t = page.meta.get('tags', [])
if isinstance(t, list):
all_tags.update(t)
return dict(all_cloud_tags=sorted(list(all_tags)))
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5001, debug=True)