Nardis
A web framework based on ASGI. This is inspired by the Express framework for node.js.
Current status
Still not production-ready.
This API is currently experimental, and is subject to change at any time.
As such, please don't use this for production applications yet.
However, please do play around with it. Any feedback at this stage is welcome as the API becomes more stable.
Requirements
Python 3.6+
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:
from nardis.asgi import main
from nardis.routing import Get as get, Post as post
import asyncio
template_start = """
<!doctype html>
<head><title>example</title></head>
<body>
"""
template_end = """
</body>
"""
async def index(req, res):
"""
This just demonstrates that you can write async code. Don't actually write this in production.
"""
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>liftoff!</p>", more=True)
await res.send(template_end)
async def hello(req, res):
"""
Try going to http://127.0.0.1:8000/hello/your_name/
You'll see "Hello, your_name!"
"""
name = req.params.get('name', 'world')
await res.send(f"<h1>Hello, {name}!</h1>")
routes = [
get(r"^/?$", index),
get(r"^/hello/(?P<name>\w+)/?$", hello),
]
config = {
'routes': routes,
}
app = main(config) # 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
Alternatively, you could also do the following:
$ uvicorn application:app
This should start a server on http://127.0.0.1:8000
Using other web servers
Currently, Uvicorn is a dependency of Nardis.
The codebase doesn't actually use Uvicorn, but this dependency allows you to run your application quickly (see above example). This dependency might be removed in the future.
Nardis 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
Metadata
Release files for nardis 0.0.7
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 | |
|---|---|---|---|---|
| nardis-0.0.7.tar.gz | 5.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nardis-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.8 kB
Release files / nardis-0.0.7.tar.gz
| Download URL | nardis-0.0.7.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
74a76e65d3dce097656471f32c9d7350d5b2778e299c528ea94b74eb14f8df88
|
|
BLAKE2b-256 checksum How to use checksums |
eed5179ea2c470f40b4473c1fb80866f4c6324b397dda87657dc020ee97b5044
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / nardis-0.0.7-py3-none-any.whl
| Download URL | nardis-0.0.7-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f0489293e54f45fa21735b2f766c7aaec9d30a96b7df8fa4f4af96c793e7bc9
|
|
BLAKE2b-256 checksum How to use checksums |
67232d3fb9f6dd8efcbb98b2320036f65a3c8d8b494481394e4396ea52d9bd64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for nardis 0.0.7
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.