bareASGI-cors
CORS support for bareASGI (read the docs)
Usage
Simply create the CORSMiddleware class and put is as the first middleware.
import json
import uvicorn
from bareasgi import (
Application,
text_reader,
text_writer
)
from bareasgi_cors import CORSMiddleware
async def get_info(request):
text = json.dumps(request.info)
return HttpResponse(200, [(b'content-type', b'application/json')], text_writer(text))
async def set_info(request):
text = await text_reader(request.body)
data = json.loads(text)
request.info.update(data)
return HttpResponse(204)
# Create the CORS middleware class
cors_middleware = CORSMiddleware()
# Use the CORS middleware as the first middleware.
app = Application(info={'name': 'Michael Caine'}, middlewares=[cors_middleware])
app.http_router.add({'GET'}, '/info', get_info)
app.http_router.add({'POST', 'OPTIONS'}, '/info', set_info)
uvicorn.run(app, port=9010)
The POST method
In the above example an OPTION method is included with the POST. This is always required with a POST as a browser will try first with an OPTION.
Metadata
Release files for bareasgi-cors 5.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bareasgi_cors-5.0.0.tar.gz | 10.1 kB | Without provenance | Details for bareasgi_cors-5.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bareasgi_cors-5.0.0-py3-none-any.whl | Python 3 | none | any | Details for bareasgi_cors-5.0.0-py3-none-any.whl |
Total release size: 20.0 kB
Release files / bareasgi_cors-5.0.0.tar.gz
| Download URL | bareasgi_cors-5.0.0.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1274a67c64e36804aa7640d6a23487c8ddcb78af69dc40bafc4202e26d64f087
|
|
BLAKE2b-256 checksum How to use checksums |
c90663c4bf4067fd97679365c1b372fba88d9d74ee51c61bf4091de45840a77b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / bareasgi_cors-5.0.0-py3-none-any.whl
| Download URL | bareasgi_cors-5.0.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
efd74d4ef6c55cd0fba2996821d5d7987c3a30f2d1ecf0c89f9f53720cefab1a
|
|
BLAKE2b-256 checksum How to use checksums |
f5cb10ef51aee33be96cd2bb8417a2468fa299090624b99847b45649190d7327
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for bareasgi-cors 5.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.