Skip to main content
# hug CORS middleware

A [hug](https://github.com/timothycrosley/hug) middleware for allowing CORS (cross-origin resource sharing) requests from hug servers.

## Installation

```bash
pip install hug_middleware_cors
```

## Usage

```python
import hug
from hug_middleware_cors import CORSMiddleware

api = hug.API(__name__)
api.http.add_middleware(CORSMiddleware(api))

@hug.post('/demo')
def demo(name: 'your name'):
return {"result": "Hello {0}".format(name)}
```

## Demoing

1. Check out this repository and navigate to its root
2. Start a hug server on port 8000 using: `hug -f server.py`
3. Start a static http server on port 8080 using `python -m http.server 8080`
4. Go to [http://localhost:8080](http://localhost:8080) to send a preflighted CORS request to the hug server.

## License
MIT License

See LICENSE for details


Metadata

Release files for hug-middleware-cors 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hug-middleware-cors 1.0.0
File Size Uploaded
hug_middleware_cors-1.0.0.tar.gz 2.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hug-middleware-cors 1.0.0
File Interpreter ABI Platform
hug_middleware_cors-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.4 kB

Release files / hug_middleware_cors-1.0.0.tar.gz

Download URL hug_middleware_cors-1.0.0.tar.gz
Size 2.3 kB
Tags Source
SHA-256 checksum
How to use checksums
96222e06db1a2748ec0ef0f51da2165faf59c69f40593a639c3f72e0b2375a58
BLAKE2b-256 checksum
How to use checksums
6f27eb58db0af6121b1a6f2ec04e7a98a33801fd79613bf540a2c808ba90761d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / hug_middleware_cors-1.0.0-py3-none-any.whl

Download URL hug_middleware_cors-1.0.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33fbc3cf5bf9cd9f62268e6cf4eac7d9ceb0385dc0669faa5113a6edffb6cd1a
BLAKE2b-256 checksum
How to use checksums
c4e246fbe122a5ca7f0dece1b46f7ce1a66cd6b01d9bdcda457600f32778dca7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page