Added cors

This commit is contained in:
Maximilian Giller 2023-10-11 02:06:38 +02:00
parent ad561a9519
commit 5390dae937
2 changed files with 18 additions and 1 deletions

View file

@ -1,4 +1,5 @@
gpiozero
luma.led_matrix
fastapi
uvicorn
uvicorn
fastapi-cors

View file

@ -2,10 +2,26 @@ from fastapi import FastAPI, HTTPException
from datetime import datetime
import requests
from matrix import MatrixDisplay
from fastapi.middleware.cors import CORSMiddleware
import asyncio
app = FastAPI()
origins = [
"http://localhost",
"http://localhost:8000",
"http://raspberrypi",
"http://192.168.178.54"
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
matrix_display = MatrixDisplay()
should_run_time_loop = True