Skip to main content

CORS middleware for the hug framework

Project description

# 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


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hug_middleware_cors-1.0.0.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

hug_middleware_cors-1.0.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file hug_middleware_cors-1.0.0.tar.gz.

File metadata

File hashes

Hashes for hug_middleware_cors-1.0.0.tar.gz
Algorithm Hash digest
SHA256 96222e06db1a2748ec0ef0f51da2165faf59c69f40593a639c3f72e0b2375a58
MD5 8fcc6611d700a7589439c94ed2c9e030
BLAKE2b-256 6f27eb58db0af6121b1a6f2ec04e7a98a33801fd79613bf540a2c808ba90761d

See more details on using hashes here.

File details

Details for the file hug_middleware_cors-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hug_middleware_cors-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33fbc3cf5bf9cd9f62268e6cf4eac7d9ceb0385dc0669faa5113a6edffb6cd1a
MD5 2bc1ac504478ebe81a804188e883f56c
BLAKE2b-256 c4e246fbe122a5ca7f0dece1b46f7ce1a66cd6b01d9bdcda457600f32778dca7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page