From 24e140a168f0703b1ab64001e84be704b358324e Mon Sep 17 00:00:00 2001 From: xiaozhou233 Date: Mon, 29 Jun 2026 21:35:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20CORS=20=E4=B8=AD=E9=97=B4?= =?UTF-8?q?=E4=BB=B6=E4=BB=A5=E6=94=AF=E6=8C=81=E8=B7=A8=E5=9F=9F=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=EF=BC=8C=E5=B9=B6=E6=96=B0=E5=A2=9E=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api-server/app.py | 9 +++++++++ api-server/run.bat | 1 + 2 files changed, 10 insertions(+) create mode 100644 api-server/run.bat diff --git a/api-server/app.py b/api-server/app.py index 7f5246f..a6edd1c 100644 --- a/api-server/app.py +++ b/api-server/app.py @@ -2,6 +2,7 @@ from fastapi import FastAPI from datetime import datetime from data import * from score import * +from fastapi.middleware.cors import CORSMiddleware ### TOKEN = "mE7yG0kI" @@ -9,6 +10,14 @@ TOKEN = "mE7yG0kI" app = FastAPI() +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=False, + allow_methods=["*"], + allow_headers=["*"], +) + @app.get("/") def root(): return "OK" diff --git a/api-server/run.bat b/api-server/run.bat new file mode 100644 index 0000000..92d9021 --- /dev/null +++ b/api-server/run.bat @@ -0,0 +1 @@ +uvicorn app:app --reload