烧瓶管理.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"

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
SpringWeb中的java更新/通知其他用户   java Lambda性能测试   java Bukkit插件:空白符号   java在按下按钮后改变彩色正方形的大小   javajavac相当于“D”?   java序列化接口   属性无法从属性文件返回值   java我应该使用什么查询来使用Jsoup从html页面提取符号?   java Android Studio项目结构问题   JAVA方法和返回值/公共变量(基础)   java将NativeQuery映射到POJO   java如何在下面的程序中消除NumberFormatException?   在java中获取链表与数组中的对象   java Android Firebase将用户发送到聊天室