Skip to main content

A nano web framework

Project description

NANO : A Nano Web Framework

Nano is an Express inspired nano web framework which is under development. Currently, it has features of adding routes, controllers and sending API responses (Refer the example blog app for reference). Defining models with custom field types is also available but is under development.

Status : Under developement

To run example app

$ pip3 install -r requirements.txt

$ python3 main.py run:<appname>

Documentation

Step 1: Install nanoAPI and create folder structure

$ pip3 install nanoAPI

$ touch models.py
$ touch controllers.py
$ touch routes.py
$ touch main.py

Step 1: Install nanoAPI and create folder structure

# models.py
from nanoAPI.db import model

class User(model.Model):
    username = model.StringType('username', max_length=50, min_length=4, unique=True, required=True)
    # define your model here

Step 2: Define your controllers

# controllers.py
from nanoAPI.handler import Response

def index(req):
    # define your controller here
    return Response(status=200, data={"msg": "message"})

Step 3: create a router and assign controllers with routes

# routes.py
from nanoAPI.handler import Router
from .controllers import index

router = Router()
router.get("/", index)

Step 4: create nanoAPI app and assemble your router and models

# main.py
from nanoAPI import nanoAPI, run
from .routes import router
from .models import User

api = nanoAPI()

api.set_router('/api', router)
api.set_models(User)

run(api)

Step 5: Boot your models to db and run the server

$ python3 main.py run:db
$ python3 main.py run:api

Refer the example blog app for folder structure. Working on a better documentation

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

nanoAPI-0.5.0.tar.gz (10.0 kB view hashes)

Uploaded Source

Built Distribution

nanoAPI-0.5.0-py3-none-any.whl (13.6 kB view hashes)

Uploaded Python 3

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