烧瓶管理.py
Mlask的Python项目详细描述
mlask给 Flask应用程序。
安装:
pip install mlask
创建第一个应用程序:
创建骨架管路:
mlask-admin.py startapp your_apps_name
此命令将使用 以下文件:
- manage.py
- 配置py
- tests.py
- views.py
对于“hello world”示例,请选中“views.py”和“tests.py”。
当您对第一个应用程序满意时,请运行以下命令启动测试服务器:
python manage.py runserver
然后运行测试我确信您已经编写了:
python manage.py test
编辑“config.py”更改服务器设置,将其他模块添加到 以及定义自己的配置。所有大写变量 “config.py”可从“app.config”模块访问。 有关烧瓶配置的详细信息:flask.pocoo.org/docs/config/。
基本上就是这样。关于全瓶文件,请访问 flask.pocoo.org/docs/api/。
所有内置命令:
runserver Starts testing server rungunicorn Starts Gunicorn server shell Starts interactive shell with defined app syncdb Creates all tables defined by SQLAlchemy declarative test Runs all tests in "config.TEST_MODULES" startapp Creates an app direcory structure for the given app name in the current directory
定义自己的命令:
创建包含以下内容的mycommands.py文件:
from mlask.management.commands import BaseCommand class ExampleCommand(BaseCommand): __command_name__ = 'example' #optional __help__ = 'Short help' #optional def update_parser(self, parser): # Define rules for parsing the input. # Check argparse for full documentation. parser.add_argument('text', help="Text to print") def run(self, options): print options.text
将“your_apps_name.mycommands”模块添加到config.py“modules”,然后 通过运行来测试:
python manage.py example "Hello"