跳转到主要内容

Web应用程序的CORS策略

项目描述

此包允许您创建一个可以处理CORS的策略。它可以与任何Python框架一起使用,因为它完全无关。它可以处理响应头,甚至对于预检请求。

示例

from roughrider.cors.policy import CORSPolicy

cors = CORSPolicy(
    methods=['GET', 'POST'],
    allow_headers=['Accept-Encoding'],
    expose_headers=['Accept-Encoding'],
    max_age=19000
)

headers = list(cors.headers())

# Arguments for the preflight should be extracted from the request.
# depending on the type of framework you use (WSGI, ASGI...)
preflight_headers = list(cors.preflight(
    origin='http://example.com',
    acr_headers='X-Custom-Header, Accept-Encoding'
))

变更记录

0.1 (2021-10-09)

  • 初始发布。

项目详情


下载文件

下载适合您平台文件的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分布

roughrider.cors-0.1.tar.gz (5.9 kB 查看哈希值)

支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面