Skip to content

Parite 1 - Setup

Warning : This project is private and is still in design, not ready for production. Create an issue if you encounter any bugs!

Make sure you have python3.6 +. Let’s start by creating a virtual environment.

$ python --version

Install Nimba

$ pip install nimba

Create nimba application

$ nimba create --app awesome_app

Structure project

  • application - Your application project (you will spend most of your time here).
    • views.py - Your logic code
    • models.py - Define here the schema of your database
    • tests.py - Write your test here
  • staticfiles - The static files.
  • templates - Your template (html page etc…).
  • settings.py - Settings database, secret key and other.
  • mask.py - the command utility, start the server, create views and many more.

Run server

In your project app awesome_app

$ python mask.py serve

Monitoring for changes...
Starting server in PID 72932
June 25, 2021 - 18:04:32
Serving on http://127.0.0.1:8000
Quit the server with CONTROL-C.
Open http://127.0.0.1:8000

You cant change port with python mask.py serve -p 7000 (runing with port 7000)
Or sharing ip python mask.py serve -s 0:7000 (0.0.0.0:7000)

Create other view

A view is a python function decorated with an url path, accepting a web request and returning a response. This response can contain html, template, xml etc.

A simple view returning html code with a decorate path. Open your views.py in your app folder

from nimba.http import router

@router('/about')
def about(request):
    return "<h1> Hello, World </h1>"

Each life is decorated by a road indicating a path

  • from nimba.http import router
  • @router('/about') the router decorator makes your function a view, it receives web requests.
  • request is the request web content all data get and post

Open http://127.0.0.1:8000/about


Continue to the tutorial Partie 2 - Endpoint