Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tim2anna/sanic-fire
https://github.com/tim2anna/sanic-fire
Last synced: 30 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/tim2anna/sanic-fire
- Owner: tim2anna
- Created: 2020-09-18T03:02:31.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-18T03:57:24.000Z (about 4 years ago)
- Last Synced: 2024-08-10T09:14:34.262Z (4 months ago)
- Language: Python
- Size: 1.95 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-sanic - sanic-fire
README
# sanic-fire
sanic-fire is an extension for Sanic that adds support for writing external commands to your application.
## install
$ pip install sanic-fire
## quick start1.Step1: Create manager.py file in your project root directory.
```
#!/usr/bin/python3
# -*- coding: utf-8 -*-from sanic_fire import cmd
from sanic_fire.core import command_class, command_func@command_class
class Hello(object):
""" Annonation """
def hello(self, value='world'):
""" hello """
return 'hello, ' + str(value)@command_func
def sync_db():
return 'init db'if __name__ == '__main__':
cmd()
```
2.Step2: Run command on terminal:
```
python3 manager.py sync_db
python3 manager.py Hello hello
```