semvec/pypi-packages huggingface dataset:
uhttp-static 0.1.3
Static files support for µHTTP
License: MIT
Requires Python: >=3.9,<4.0

# µHTTP Static

Static files support for µHTTP

In production, use [Unit](https://unit.nginx.org/) instead.

### Installation

µHTTP Static is on [PyPI](https://pypi.org/project/uhttp-static/).

```bash
pip install uhttp-static
```

### Usage

```python
from uhttp import App
from uhttp_static import send_file, static


app = App()
app.mount(static('assets'), '/assets')


@app.get('/')
def hello(request):
    return send_file('hello.html')
```

### License

Released under the MIT license.
uhttp-session 0.2.0
Session support for µHTTP
License: MIT
Requires Python: >=3.9,<4.0

# µHTTP Session

Session support for µHTTP

Sessions are implemented as [Javascript Web Signatures](https://datatracker.ietf.org/doc/html/rfc7515). Which means that:

1. Sessions are stored in the client's browser.
2. Sessions are not secret.
3. Sessions cannot be tempered with.

### Installation

µHTTP Session is on [PyPI](https://pypi.org/project/uhttp-session/).

```bash
pip install uhttp-session
```

### Usage

First, you must set the secret key as an environment variable:

```bash
export APP_SECRET='<your secret key goes here>'
```

Don't have one?

```bash
python -c 'import secrets; print(secrets.token_hex())'
```

Then:

```python
from uhttp import App, Response
from uhttp_session import session

app = App()
app.mount(session())

@app.post('/login')
def login(request):
    request.state['session']['user'] = request.form.get('user', 'john')
    return Response(302, headers={'location': '/'})

@app.get('/')
def account(request):
    if 'user' not in request.state['session']:
        return 401
    else:
        return f'Hello, {request.state["session"]["user"]}!'
```

### License

Released under the MIT license.
uhttp-multipart 0.2.0
Multipart support for µHTTP
License: MIT
Requires Python: >=3.9,<4.0

# µHTTP Multipart

Multipart support for µHTTP

### Installation

µHTTP Multipart is on [PyPI](https://pypi.org/project/uhttp-multipart/).

```bash
pip install uhttp-multipart
```

### Usage

Only parse when required:

```python
from uhttp import App
from uhttp_multipart import parse_form

app = App()

@app.post('/')
def submit(request):
    form = parse_form(request.form)
```

Always parse `multipart/form-data` requests (middleware):

```python
from uhttp import App
from uhttp_multipart import multipart

app = App()
app.mount(mutipart())
```

The function `parse_form` (which is also used in the middleware) returns a `MultiDict`. Form fields are `str`, file fields are `BytesIO`.

### License

Released under the MIT license.