From d592a0908a3273daf5b16bd31ead2fd518148299 Mon Sep 17 00:00:00 2001 From: Anekdotin Date: Thu, 16 May 2024 14:39:57 -0400 Subject: [PATCH] Updates --- app/main.py | 20 ++++++++++++++++++-- app/routers/command.py | 5 ++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/main.py b/app/main.py index 29d0ff6..3d09190 100644 --- a/app/main.py +++ b/app/main.py @@ -1,9 +1,10 @@ from fastapi import FastAPI -from app.routers import (cron_print, printstatus, +from app.routers import (cron_print, + printstatus, command, ) - +from fastapi.middleware.cors import CORSMiddleware @@ -15,6 +16,21 @@ app.include_router(printstatus.router) app.include_router(command.router) app.include_router(cron_print.router) +origins = [ + "http://localhost:9000", + "https://localhost:5173", + "http://localhost", + "*", + +] + +app.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) @app.get("/") diff --git a/app/routers/command.py b/app/routers/command.py index f24c3c7..bf1ae18 100644 --- a/app/routers/command.py +++ b/app/routers/command.py @@ -12,9 +12,8 @@ router = APIRouter( ) -@router.get("/printticket/{delivery_id}") -async def print_specific_ticket(delivery_id): - +@router.options("/printticket/{delivery_id}") +async def print_specific_ticket(delivery_id: int): now = datetime.utcnow() get_ticket = (session.query(Delivery)