https://github.com/void-verse/void-proton
A proton sized python framework for building backend web applications, from void. [PIP PACKAGE]
https://github.com/void-verse/void-proton
backend-framework pip-package python-package web-framework wsgi-server
Last synced: 3 months ago
JSON representation
A proton sized python framework for building backend web applications, from void. [PIP PACKAGE]
- Host: GitHub
- URL: https://github.com/void-verse/void-proton
- Owner: void-verse
- License: bsd-3-clause
- Created: 2022-07-06T10:49:41.000Z (over 3 years ago)
- Default Branch: prod
- Last Pushed: 2022-07-07T03:55:33.000Z (over 3 years ago)
- Last Synced: 2025-06-05T14:42:21.178Z (9 months ago)
- Topics: backend-framework, pip-package, python-package, web-framework, wsgi-server
- Language: Python
- Homepage: https://pypi.org/project/void-proton
- Size: 11.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PROTON : A proton sized web framework
Proton is an Express inspired proton sized web framework for building backend web applications from [void](https://github.com/void-verse). Currently, it has features of adding routes, controllers and sending API responses (Refer the [example blog app](https://github.com/NandanunniAS/Nano-Blog-App) for reference). Defining models with custom field types is also available but is under development.
**Status** : Under developement
### To run example app
```bash
$ pip3 install -r requirements.txt
$ python3 main.py run:
```
## Documentation
**Step 1**: Install proton and create folder structure
```bash
$ pip3 install proton-py
$ touch models.py
$ touch controllers.py
$ touch routes.py
$ touch main.py
```
**Step 2**: Define your models
```python
# models.py
from proton.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
```python
# controllers.py
from proton.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
```python
# routes.py
from proton.handler import Router
from .controllers import index
router = Router()
router.get("/", index)
```
**Step 4**: create proton app and assemble your router and models
```python
# main.py
from proton import Proton, run
from .routes import router
from .models import User
api = Proton()
api.set_router('/api', router)
api.set_models(User)
run(api)
```
**Step 5**: Boot your models to db and run the server
```bash
$ python3 main.py run:db
$ python3 main.py run:api
```
Refer the [example blog app](https://github.com/NandanunniAS/Nano-Blog-App) for folder structure. Working on a better documentation