26 lines
839 B
Python
26 lines
839 B
Python
# -*- coding: utf-8 -*-
|
|
from application import app
|
|
import www
|
|
from jobs.launcher import register_runjob_command
|
|
import click
|
|
import sys
|
|
|
|
# 初始化任务命令
|
|
register_runjob_command()
|
|
|
|
# 定义 Flask CLI 命令(服务启动)
|
|
@app.cli.command("runserver")
|
|
@click.option("--host", default="0.0.0.0", help="Server host")
|
|
@click.option("--port", default=None, help="Server port")
|
|
def start_server(host, port):
|
|
"""启动开发服务器"""
|
|
if port is None:
|
|
port = app.config.get('SERVER_PORT', 8032)
|
|
app.run(host=host, port=port, debug=app.config.get('DEBUG', False))
|
|
|
|
if __name__ == '__main__':
|
|
if len(sys.argv) > 1 and sys.argv[1] == 'runserver':
|
|
port = app.config.get('SERVER_PORT', 8032)
|
|
app.run(host="0.0.0.0", port=port, debug=app.config.get('DEBUG', False))
|
|
else:
|
|
app.cli.main() |