feat: 允许跨域
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
gaze 2023-07-30 21:13:38 +08:00
parent 881db673c7
commit 24a6a49598

12
api.py
View File

@ -3,13 +3,21 @@ import os
import requests import requests
import uvicorn import uvicorn
from fastapi.responses import FileResponse
from fastapi import FastAPI from fastapi import FastAPI
from fastapi import FastAPI, Form from fastapi.middleware.cors import CORSMiddleware
env = os.environ env = os.environ
app = FastAPI() app = FastAPI()
# 配置 CORS 中间件
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # 允许所有来源,可以根据需求进行配置
allow_credentials=True,
allow_methods=["*"], # 允许所有请求方法
allow_headers=["*"], # 允许所有请求头
)
# 榜单获取 # 榜单获取
@app.get("/get_rank") @app.get("/get_rank")