new babycode format for new style

This commit is contained in:
2026-04-13 23:26:11 +03:00
parent 4aa4e58c58
commit dd54f5fe33
2 changed files with 51 additions and 37 deletions

View File

@@ -196,6 +196,19 @@ def create_app():
cache.init_app(app)
from app.routes.app import bp as app_bp
from app.routes.topics import bp as topics_bp
from app.routes.threads import bp as threads_bp
from app.routes.users import bp as users_bp
from app.routes.guides import bp as guides_bp
from app.routes.mod import bp as mod_bp
app.register_blueprint(app_bp)
app.register_blueprint(topics_bp)
app.register_blueprint(threads_bp)
app.register_blueprint(users_bp)
app.register_blueprint(guides_bp)
app.register_blueprint(mod_bp)
with app.app_context():
from .schema import create as create_tables
from .migrations import run_migrations
@@ -222,19 +235,6 @@ 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
from app.routes.threads import bp as threads_bp
from app.routes.users import bp as users_bp
from app.routes.guides import bp as guides_bp
from app.routes.mod import bp as mod_bp
app.register_blueprint(app_bp)
app.register_blueprint(topics_bp)
app.register_blueprint(threads_bp)
app.register_blueprint(users_bp)
app.register_blueprint(guides_bp)
app.register_blueprint(mod_bp)
@app.context_processor
def inject_constants():
return {
@@ -254,6 +254,7 @@ def create_app():
'get_motds': MOTD.get_all,
'get_time_now': lambda: int(time.time()),
'is_logged_in': is_logged_in,
'is_mod': lambda: is_logged_in() and get_active_user().is_mod(),
'get_active_user': get_active_user,
'get_post_url': get_post_url,
}
@@ -289,14 +290,14 @@ 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(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):