Added cors
This commit is contained in:
parent
ad561a9519
commit
5390dae937
2 changed files with 18 additions and 1 deletions
|
@ -2,3 +2,4 @@ gpiozero
|
|||
luma.led_matrix
|
||||
fastapi
|
||||
uvicorn
|
||||
fastapi-cors
|
16
src/main.py
16
src/main.py
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue