feat: Add basic frontend

This commit is contained in:
Piotr Gaczkowski 2026-03-24 15:39:18 +01:00
parent 2a2b5973df
commit e3ce4c0920
14 changed files with 7474 additions and 28 deletions

View file

@ -5,9 +5,15 @@ from labeler.infra.e550w_printer.printer import E550W
from labeler.infra.renderer import PILRenderer
from fastapi import FastAPI
from fastapi.responses import HTMLResponse, RedirectResponse
from fastapi.staticfiles import StaticFiles
from fegen import discourse, main
app = FastAPI()
app.mount("/static", StaticFiles(directory="fegen/docs/static"), name="static")
class LabelingBot:
def __init__(self, app: Application):
@ -65,6 +71,11 @@ class LabelingBot:
# await update.message.reply_text("Cancelled.")
# return ConversationHandler.END
@app.get("/", response_class=HTMLResponse)
async def root():
with open("fegen/docs/index.html", "r") as f:
index = f.read()
return index
@app.get("/print/{item_id}")
def print_item(item_id: int, q: str | None = None):
@ -78,3 +89,10 @@ def print_item(item_id: int, q: str | None = None):
with open("label.png", "wb") as preview:
preview.write(label.bytes)
bot.print_qrcode(item_id, 25)
return RedirectResponse(url="/", status_code=302)
@app.get("/refresh")
def refresh():
discourse.DiscourseDatabase()
main.generate_dashboard()
return RedirectResponse(url="/", status_code=302)