All Projects → yoongkang → nardis

yoongkang / nardis

Licence: MIT license
A small web framework based on ASGI

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to nardis

Sanic
Async Python 3.7+ web server/framework | Build fast. Run fast.
Stars: ✭ 15,660 (+111757.14%)
Mutual labels:  web-framework, asyncio, asgi
Javalite
JavaLite is a cohesive collection of frameworks designed from ground up to add pleasure back to your daily life
Stars: ✭ 753 (+5278.57%)
Mutual labels:  web-development, web-framework
Toa
A pithy and powerful web framework.
Stars: ✭ 220 (+1471.43%)
Mutual labels:  web-framework, async-await
Toruk
Go web 开发脚手架
Stars: ✭ 78 (+457.14%)
Mutual labels:  web-development, web-framework
Bocadillo
(UNMAINTAINED) Fast, scalable and real-time capable web APIs for everyone
Stars: ✭ 401 (+2764.29%)
Mutual labels:  web-framework, asyncio
Kretes
A Programming Environment for TypeScript & Node.js built on top of VS Code
Stars: ✭ 570 (+3971.43%)
Mutual labels:  web-framework, async-await
Thruster
A fast, middleware based, web framework written in Rust
Stars: ✭ 671 (+4692.86%)
Mutual labels:  web-development, web-framework
tomodachi
💻 Microservice library / framework using Python's asyncio event loop with full support for HTTP + WebSockets, AWS SNS+SQS, RabbitMQ / AMQP, middleware, etc. Extendable for GraphQL, protobuf, gRPC, among other technologies.
Stars: ✭ 170 (+1114.29%)
Mutual labels:  asyncio, async-await
ninglex
Easy to learn, quick and dirty, bare-bones web framework for Common Lisp
Stars: ✭ 31 (+121.43%)
Mutual labels:  web-development, web-framework
Rocket
A web framework for Rust.
Stars: ✭ 15,760 (+112471.43%)
Mutual labels:  web-development, web-framework
Aiohttp admin
admin interface for aiohttp application http://aiohttp-admin.readthedocs.io
Stars: ✭ 207 (+1378.57%)
Mutual labels:  asyncio, async-await
aioflask
Flask running on asyncio!
Stars: ✭ 192 (+1271.43%)
Mutual labels:  asyncio, async-await
Aioodbc
aioodbc - is a library for accessing a ODBC databases from the asyncio
Stars: ✭ 206 (+1371.43%)
Mutual labels:  asyncio, async-await
Emmett
The web framework for inventors
Stars: ✭ 647 (+4521.43%)
Mutual labels:  web-framework, asyncio
Aiomisc
aiomisc - miscellaneous utils for asyncio
Stars: ✭ 200 (+1328.57%)
Mutual labels:  asyncio, async-await
Aiozipkin
Distributed tracing instrumentation for asyncio with zipkin
Stars: ✭ 161 (+1050%)
Mutual labels:  asyncio, async-await
Aiormq
Pure python AMQP 0.9.1 asynchronous client library
Stars: ✭ 112 (+700%)
Mutual labels:  asyncio, async-await
Cppcoro
A library of C++ coroutine abstractions for the coroutines TS
Stars: ✭ 2,118 (+15028.57%)
Mutual labels:  asyncio, async-await
Denovel
A Deno Framework For Web Artisan - Inspired by Laravel
Stars: ✭ 128 (+814.29%)
Mutual labels:  web-development, web-framework
fastapi-azure-auth
Easy and secure implementation of Azure AD for your FastAPI APIs 🔒 B2C, single- and multi-tenant support.
Stars: ✭ 174 (+1142.86%)
Mutual labels:  asyncio, asgi

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].