start the new topics route and view

This commit is contained in:
2026-04-12 23:36:50 +03:00
parent 099b5c135e
commit ce9bca0a75
11 changed files with 141 additions and 34 deletions

View File

@@ -1,7 +1,7 @@
from flask import Flask, session, request, render_template
from dotenv import load_dotenv
from .models import Avatars, Users, PostHistory, Posts, MOTD, BadgeUploads, Sessions
from .auth import digest
from .auth import digest, is_logged_in
from .constants import (
PermissionLevel, permission_level_string,
InfoboxKind, InfoboxHTMLClass,
@@ -221,6 +221,11 @@ def create_app():
with open('.git/refs/heads/main') as f:
commit = f.read().strip()
from app.routes.app import bp as app_bp
from app.routes.topics import bp as topics_bp
app.register_blueprint(app_bp)
app.register_blueprint(topics_bp)
@app.context_processor
def inject_constants():
return {
@@ -239,6 +244,7 @@ def create_app():
return {
'get_motds': MOTD.get_all,
'get_time_now': lambda: int(time.time()),
'is_logged_in': is_logged_in,
}
@app.template_filter('ts_datetime')
@@ -268,23 +274,23 @@ def create_app():
def basename_noext(subj):
return os.path.splitext(os.path.basename(subj))[0]
@app.errorhandler(404)
def _handle_404(e):
if request.path.startswith('/hyperapi/'):
return '<h1>not found</h1>', e.code
elif request.path.startswith('/api/'):
return {'error': 'not found'}, e.code
else:
return render_template('common/404.html'), e.code
@app.errorhandler(413)
def _handle_413(e):
if request.path.startswith('/hyperapi/'):
return '<h1>request body too large</h1>', e.code
elif request.path.startswith('/api/'):
return {'error': 'body too large'}, e.code
else:
return render_template('common/413.html'), e.code
# @app.errorhandler(404)
# def _handle_404(e):
# if request.path.startswith('/hyperapi/'):
# return '<h1>not found</h1>', e.code
# elif request.path.startswith('/api/'):
# return {'error': 'not found'}, e.code
# else:
# return render_template('common/404.html'), e.code
#
# @app.errorhandler(413)
# def _handle_413(e):
# if request.path.startswith('/hyperapi/'):
# return '<h1>request body too large</h1>', e.code
# elif request.path.startswith('/api/'):
# return {'error': 'body too large'}, e.code
# else:
# return render_template('common/413.html'), e.code
# this only happens at build time but
# build time is when updates are done anyway