https://github.com/aiscenblue/sanic-framework-starterkit
Sanic framework application boilerplate project
https://github.com/aiscenblue/sanic-framework-starterkit
flask flask-api flask-application flask-backend python python3 sanic sanic-boilerplat sanic-explore sanic-for-pythoner sanic-framework sanic-project
Last synced: about 1 month ago
JSON representation
Sanic framework application boilerplate project
- Host: GitHub
- URL: https://github.com/aiscenblue/sanic-framework-starterkit
- Owner: aiscenblue
- License: mit
- Created: 2017-10-20T20:00:48.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-28T06:53:25.000Z (over 8 years ago)
- Last Synced: 2025-01-22T12:45:45.164Z (over 1 year ago)
- Topics: flask, flask-api, flask-application, flask-backend, python, python3, sanic, sanic-boilerplat, sanic-explore, sanic-for-pythoner, sanic-framework, sanic-project
- Language: Python
- Homepage: https://github.com/aiscenblue/sanic-framework-starterkit
- Size: 12.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
**Requirements:**
```
Python 3.5 or higher
Windows Environment: N/A
```
**Install requirements**
`pip3 install -r requirements.txt`
**Setup configuration**
```
open: config/app.py
HOST = "0.0.0.0"
DEBUG = True / False
PORT = 8000
WORKERS = 4 # workers: Number of processes received before it is respected
```
**RUN sanic**
`python3 run.py`
```
2017-09-25 10:52:54 - (sanic)[DEBUG]:
▄▄▄▄▄
▀▀▀██████▄▄▄ _______________
▄▄▄▄▄ █████████▄ / \
▀▀▀▀█████▌ ▀▐▄ ▀▐█ | Gotta go fast! |
▀▀█████▄▄ ▀██████▄██ | _________________/
▀▄▄▄▄▄ ▀▀█▄▀█════█▀ |/
▀▀▀▄ ▀▀███ ▀ ▄▄
▄███▀▀██▄████████▄ ▄▀▀▀▀▀▀█▌
██▀▄▄▄██▀▄███▀ ▀▀████ ▄██
▄▀▀▀▄██▄▀▀▌████▒▒▒▒▒▒███ ▌▄▄▀
▌ ▐▀████▐███▒▒▒▒▒▐██▌
▀▄▄▄▄▀ ▀▀████▒▒▒▒▄██▀
▀▀█████████▀
▄▄██▀██████▀█
▄██▀ ▀▀▀ █
▄█ ▐▌
▄▄▄▄█▌ ▀█▄▄▄▄▀▀▄
▌ ▐ ▀▀▄▄▄▀
▀▀▄▄▀
2017-09-25 10:52:54 - (sanic)[INFO]: Goin' Fast @ http://0.0.0.0:8000
2017-09-25 10:52:54 - (sanic)[INFO]: Starting worker [24478]
2017-09-25 10:52:54 - (sanic)[INFO]: Starting worker [24479]
2017-09-25 10:52:54 - (sanic)[INFO]: Starting worker [24480]
2017-09-25 10:52:54 - (sanic)[INFO]: Starting worker [24481]
```
**Register blueprint route**
`NOTE :: if it's a sub directory it must consist a __init__.py
file to be recognize as a package`
```
from sanic import Blueprint
from sanic.response import json
from http import HTTPStatus
""" blueprint module for url handler """
module_name = 'index' # module name to be registered in the blueprint
or just change the 'index' string to get_file_name(__file__)
it uses the current filename as the root url of your api module
module_name = get_file_name(__file__)
method = Blueprint(module_name, url_prefix='/')
""" http code status """
__status = HTTPStatus # status codes library
@method.route("/", methods=['GET'])
async def index(requests):
return json("Welcome to sanic!", __status.OK)
```
**READ MORE:** ``https://github.com/channelcat/sanic/``