feat: support cors
This commit is contained in:
parent
756989c302
commit
8b4362fd6a
9
main.py
9
main.py
@ -1,4 +1,5 @@
|
||||
from fastapi import FastAPI # 导入FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
import uvicorn # uvicorn:主要用于加载和提供应用程序的服务器
|
||||
import requests
|
||||
import json
|
||||
@ -16,6 +17,14 @@ headers = {
|
||||
# 创建一个app实例
|
||||
app = FastAPI() if env.get("docs") is not None and env.get("docs").lower() == "true" else FastAPI(openapi_url=None)
|
||||
|
||||
# 配置 CORS 中间件
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"], # 允许所有来源,可以根据需求进行配置
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"], # 允许所有请求方法
|
||||
allow_headers=["*"], # 允许所有请求头
|
||||
)
|
||||
|
||||
# 获取酷我cookie
|
||||
url = 'https://www.kuwo.cn/'
|
||||
|
Loading…
Reference in New Issue
Block a user