参数全部从外部读取
This commit is contained in:
33
server.py
Normal file
33
server.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from fastapi import FastAPI
|
||||
import uvicorn
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class CalculationParameter(BaseModel):
|
||||
loop: str # single or double 回路数
|
||||
insulator_c_len: float # 绝缘长度
|
||||
string_c_len: float # 导线串长
|
||||
string_g_len: float # 地线串长
|
||||
td: int # 雷暴日
|
||||
h_g_avr_sag: float # 地线平均弧垂
|
||||
h_c_avr_sag: float # 导线平均弧垂
|
||||
h_whole: float # 杆塔全高
|
||||
gc_x: tuple[float] # 导、地线水平坐标
|
||||
ground_angels: tuple[float] # 地面倾角,向下为正
|
||||
|
||||
|
||||
fastapi_app = FastAPI()
|
||||
|
||||
|
||||
@fastapi_app.post("/calculation")
|
||||
async def calculation(cp: CalculationParameter):
|
||||
print(cp)
|
||||
return {"Hello": "World"}
|
||||
|
||||
|
||||
def server_start():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run("server:fastapi_app", host="127.0.0.1", port=5000, log_level="info")
|
||||
Reference in New Issue
Block a user