From 24a6a49598d5da7ba60d31b5fb7e51b0854cc80e Mon Sep 17 00:00:00 2001 From: gaze Date: Sun, 30 Jul 2023 21:13:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=81=E8=AE=B8=E8=B7=A8=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/api.py b/api.py index d611b8d..b8ea91c 100644 --- a/api.py +++ b/api.py @@ -3,13 +3,21 @@ import os import requests import uvicorn -from fastapi.responses import FileResponse from fastapi import FastAPI -from fastapi import FastAPI, Form +from fastapi.middleware.cors import CORSMiddleware env = os.environ app = FastAPI() +# 配置 CORS 中间件 +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], # 允许所有来源,可以根据需求进行配置 + allow_credentials=True, + allow_methods=["*"], # 允许所有请求方法 + allow_headers=["*"], # 允许所有请求头 +) + # 榜单获取 @app.get("/get_rank")