Metadata-Version: 2.1
Name: nardis
Version: 0.0.4
Summary: A web framework based on ASGI
Home-page: https://github.com/yoongkang/nardis
Author: Yoong Kang Lim
Author-email: yoongkang.lim@gmail.com
License: MIT
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: typing-extensions
Requires-Dist: uvicorn


# Nardis

A web framework based on ASGI. This is inspired by the Express framework for node.js.

# Current status

This API is *extremely* experimental, and is subject to change at any time.

I do not recommend using it for production purposes, but I would love to get feedback.


# Requirements

Written with Python 3.7, no guarantee it will work on earlier versions (although I think 3.6 would work fine).

# Installation

## Via pip

Run the following:

```
$ pip install nardis
```

## From source

To build from source, clone this repo, and then:

```
$ python setup.py install
```

# Example

Here's a quick example you can use. Create an `application.py` and copy and paste this:

```python
from nardis.asgi import main
from nardis.routing import Get, Post
import asyncio


template_start = """
<!doctype html>
<head><title>example</title></head>
<body>
  <h1>He's down!</h1>
"""

template_end = """
</body>
"""

async def index(req, res):
    await res.send(template_start, more=True)
    for x in range(10, 0, -1):
        await res.send(f"<p>{x}!</p>", more=True)
        await asyncio.sleep(1)
    await res.send("<p>It's over. TKO!</p>", more=True)
    await res.send(template_end)


routes = [
    Get(r"^/?$", index),
]

app = main(routes)  # this is the ASGI application

if __name__ == '__main__':
    from uvicorn.run import run
    run(app, '127.0.0.1', 8000)
```

And then:

```
$ python application.py
```

This should start a server on http://127.0.0.1


# Using other web servers

Uvicorn is currently a dependency of Nargis for local development.

Nargis should also work with other ASGI-based web servers, like Daphne.

To get Daphne working with the example code above, you could do the following:

```
$ daphne application:app
```


