!5 启动项目增加IP和端口选项

Merge pull request !5 from 刘建/N/A
This commit is contained in:
ktianc 2023-06-06 13:44:07 +00:00 committed by Gitee
commit 9b0918ecf4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# @version : 1.0 # @version : 1.0
# @Create Time : 2021/10/19 15:47 # @Creaet Time : 2021/10/19 15:47
# @File : main.py # @File : main.py
# @IDE : PyCharm # @IDE : PyCharm
# @desc : 主程序入口 # @desc : 主程序入口
@ -67,14 +67,14 @@ def create_app():
@shell_app.command() @shell_app.command()
def run(): def run(host: str=typer.Option(default='0.0.0.0', help='监听主机IP默认开放给本网络所有主机'), port: int=typer.Option(default=9000, help='监听端口')):
""" """
启动项目 启动项目
factory: 在使用 uvicorn.run() 启动 ASGI 应用程序时可以通过设置 factory 参数来指定应用程序工厂 factory: 在使用 uvicorn.run() 启动 ASGI 应用程序时可以通过设置 factory 参数来指定应用程序工厂
应用程序工厂是一个返回 ASGI 应用程序实例的可调用对象它可以在启动时动态创建应用程序实例 应用程序工厂是一个返回 ASGI 应用程序实例的可调用对象它可以在启动时动态创建应用程序实例
""" """
uvicorn.run(app='main:create_app', host="0.0.0.0", port=9000, lifespan="on", factory=True) uvicorn.run(app='main:create_app', host=host, port=port, lifespan="on", factory=True)
@shell_app.command() @shell_app.command()