start stubbing out endpoints

This commit is contained in:
2026-04-13 20:03:26 +03:00
parent ce9bca0a75
commit 4aa4e58c58
14 changed files with 304 additions and 48 deletions

16
app/util.py Normal file
View File

@@ -0,0 +1,16 @@
from flask import url_for
from .models import Posts, Threads
def get_post_url(post_id, _anchor=False, external=False):
post = Posts.find({'id': post_id})
if not post:
return ''
thread = Threads.find({'id': post.thread_id})
anchor = None if not _anchor else f'post-{post_id}'
return url_for('threads.thread', slug=thread.slug, after=post_id, _external=external, _anchor=anchor)
def dict_to_query_string(d) -> str:
return '?' + '&'.join([f'{key}={str(value)}' for key, value in d.items()])