feat: Add basic frontend
This commit is contained in:
parent
2a2b5973df
commit
85ebe548a2
24 changed files with 237 additions and 28 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue