1 Star 0 Fork 5

qiaqia/OnmyojiAutoScript

forked from 黄晟/OnmyojiAutoScript 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
server.py 1.74 KB
一键复制 编辑 原始数据 按行查看 历史
黄晟 提交于 2024-07-06 13:48 . test(server): Auto update with git pull
# This Python file uses the following encoding: utf-8
# Copy from https://github.com/LmeSzinc/AzurLaneAutoScript/gui.py
import threading
from module.logger import logger
from module.server.setting import State
def fun(ev: threading.Event):
import argparse
import asyncio
import sys
import uvicorn
# 不知道干啥的照着抄就行了
if sys.platform.startswith("win"):
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
State.restart_event = ev
parser = argparse.ArgumentParser(description="Alas web service")
parser.add_argument(
"--host",
type=str,
help="Host to listen. Default to WebuiHost in deploy setting",
)
parser.add_argument(
"-p",
"--port",
type=int,
help="Port to listen. Default to WebuiPort in deploy setting",
)
parser.add_argument(
"-k", "--key", type=str, help="Password of alas. No password by default"
)
parser.add_argument(
"--cdn",
action="store_true",
help="Use jsdelivr cdn for pywebio static files (css, js). Self host cdn by default.",
)
parser.add_argument(
"--run",
nargs="+",
type=str,
help="Run alas by config names on startup",
)
args, _ = parser.parse_known_args()
host = args.host or State.deploy_config.WebuiHost or "0.0.0.0"
port = args.port or int(State.deploy_config.WebuiPort) or 22270
logger.hr("Launcher config")
logger.attr("Host", host)
logger.attr("Port", port)
logger.attr("Reload", ev is not None)
uvicorn.run("module.server.app:fastapi_app",
host=host,
port=port,
factory=True)
if __name__ == "__main__":
fun(None)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/zhao-shukang/OnmyojiAutoScript.git
git@gitee.com:zhao-shukang/OnmyojiAutoScript.git
zhao-shukang
OnmyojiAutoScript
OnmyojiAutoScript
master

搜索帮助