Inspira is a lightweight framework for building asynchronous web applications.
Make sure you have Python and pip
installed on your system.
# Create a new directory for your project
$ mkdir myproject
$ cd myproject
Create and activate a virtual environment
$ python -m venv venv
$ source venv/bin/activate
Install Inspira
$ pip install inspira
To generate a new app for your project, run the following command:
$ inspira init
After running the init
command, the directory structure of your project should look like the following:
├── main.py
├── src
│ ├── __init__.py
│ ├── controller
│ │ └── __init__.py
│ ├── model
│ │ └── __init__.py
│ ├── repository
│ │ └── __init__.py
│ └── service
│ └── __init__.py
└── tests
└── __init__.py
Use the following command to generate a database file:
$ inspira new database --name mydb --type sqlite
This command will create a new database file named mydb
with SQLite
as the database type.
The generated database file (database.py
) will typically contain initial configurations and may look like this:
from sqlalchemy import create_engine
from sqlalchemy.orm import declarative_base, scoped_session, sessionmaker
engine = create_engine("sqlite:///mydb.db")
db_session = scoped_session(
sessionmaker(autocommit=False, autoflush=False, bind=engine)
)
Base = declarative_base()
Base.query = db_session.query_property()
To generate necessary controller for your project, run the following command:
$ inspira new controller order
To generate repository file, run the following command:
$ inspira new repository order
To generate service file, run the following command:
$ inspira new service order
To generate model file, run the following command:
$ inspira new model order
After generating your app and setting up the necessary resources, start the server with the following command:
$ uvicorn main:app --reload
Documentation: https://www.inspiraframework.com/
This project is licensed under the terms of the MIT license.