Skip to content

HorsemanWSGI/roughrider.cors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

roughrider.cors

This package allows you to create a policy that can handle CORS. It can be used with any python framework as it's totally agnostic. It can cook response headers, even for preflight requests.

Example

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'
))

About

Set CORS policies on your WEB Applications

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages