importtyper app = typer.Typer(help="人脸检测模型") @app.command() deftrain_data(train_folder: str, test_folder: str, rate: float =0.8): """ 训练人脸检测模型 """ print(f'使用文件夹{train_folder}中的数据进行训练') print(f'使用{test_fo...
我们来看看: import typerapp = typer.Typer(help="人脸检测模型")@app.command()def train_data(train_folder: str, test_folder: str, rate: float = 0.8):"""训练人脸检测模型"""print(f'使用文件夹{train_folder}中的数据进行训练')print(f'使用{test_folder}中的数据用来验证训练效果,确保准确率>{...
@app.on_event("startup")defstart_command_listener():asyncio.create_task(commandA(a_queue))asyncio.create_task(commandB(b_queue))asyncio.create_task(commandC(c_queue))if__name__=="__main__":uvicorn.run(app=app,port=9000) 这个版本里用了@app.on_event("startup")这个装饰器,然后在里面...
command:事务中运行的dnf命令 date:执行事务的日期和时间 然后修改main.py文件将相关的数据结构添加进去。 from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class DnfTransaction(BaseModel): id: int command: str date: str FastAPI 自带的 库让你可以轻松定义一个数据类,其中的类型...
About the commandfastapi dev main.py... The commandfastapi devreads yourmain.pyfile, detects theFastAPIapp in it, and starts a server usingUvicorn. By default,fastapi devwill start with auto-reload enabled for local development. You can read more about it in theFastAPI CLI docs. ...
执行shell命令; def runDir(self, sshCommand:"Linux命令行语句", dir): if not os.path.isdir(dir): return "目标路径错误,必须是目录" with self.cd(dir):#with表示,with块的代码是在dir目录下执行; return self.runCommand(sshCommand) #解压.tar.gz文件; def decomTarGz(sel...
Then just start your app without calling the env file in the command: python -m uvicorn main:app --reload The curl output should be something like this: curl http://127.0.0.1:8000/info {"foo":"bar"} Share Follow answered Sep 15, 2022 at 9:02 dmomcilo 1144 bronze badges Add ...
# On Windows (command prompt): \path\to\venv\Scripts\activate.bat # On Windows (PowerShell): \path\to\venv\Scripts\Activate.ps1 (一些认识Python的IDE也可以被配置为激活当前的虚拟环境)。 现在,安装FastAPI: $ pip3 install fastapi FastAPI是一个构建API的框架,但为了测试你的API,你需要一个本地的...
def runCommand(self, sshCommand:"Linux命令行语句"): #top命令尚未测试通过; #如果命令行中包含路径,最好使用绝对路径; try: #语法:run('远程命令') result = self.con.run(sshCommand, hide=True) if result.return_code == 0:# 返回码,0表示正确执行,1表示错误 ...
About the commandfastapi dev main.py... The commandfastapi devreads yourmain.pyfile, detects theFastAPIapp in it, and starts a server usingUvicorn. By default,fastapi devwill start with auto-reload enabled for local development. You can read more about it in theFastAPI CLI docs. ...