本文主要是介绍zdppy 自定义跨域配置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
zdppy 自定义跨域配置
import zdppy_api as api
import zdppy_env as env
import zdppy_mcrud as mcrud
from zdppy_api.middleware import Middleware, CORSMiddlewareimport routesenv.load(".env")db = mcrud.new_env()def cors(allow_origins=['*']):"""跨域中间件"""allow_headers = {"Accept", "Accept-Language", "Content-Language", "Content-Type", "Token", "Authorization"}return Middleware(CORSMiddleware,allow_origins=allow_origins,allow_headers=allow_headers,)app = api.Api(routes=[*routes.get_routes(db),],middleware=[cors()],
)if __name__ == "__main__":import zdppy_uvicornzdppy_uvicorn.run(app, host="0.0.0.0", port=18888)
这篇关于zdppy 自定义跨域配置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!