烧瓶管理.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第三方库


热门话题
DIIOP_IOR中的java端口0。TXT,我如何更改它?   hadoop面临的问题:java。lang.NoClassDefFoundError:org/bouncycastle/jcajce/JcaJceHelper在使用更新的BC jar时   java将大科学数转换为长科学数   Java8文件流,如何控制文件的关闭?   是否有类似于dotnetshoutout的资源。com&dotnetkicks。Java世界中的com?   java返回类型void/方法替代方案?   如何使用java。lang.NullPointerException:void 安卓。支持v7。应用程序。ActionBar。setElevation(float)“”在空对象引用上'   java使用kafka流获取时间窗口中给定密钥的最后一个事件   java多边形旋转不正确   java我们应该在params中编写什么。jpbc的属性文件   java如何计算线程数?   使用jar时发生java错误,但不在库本身中   java优先级列表排队方法错误   java和org之间的区别。莫基托。莫基托。任何和组织。莫基托。媒人。任何