Add method addcurve and deletecurve

This commit is contained in:
DingZQ
2022-11-05 09:42:04 +08:00
parent 21474192be
commit c31cfd319c

17
main.py
View File

@@ -915,14 +915,29 @@ async def fastapi_set_pattern_properties(network: str, pattern: str, req: Reques
async def fast_get_curve_schema(network: str) -> dict[str, dict[str, Any]]:
return get_curve_schema(network)
@app.post("/addcurve/")
async def fastapi_add_curve(network: str, curve: str, c_type: str, req: Request) -> ChangeSet:
props = await req.json()
ps = {
'id' : curve,
'c_type': c_type
} | props
return add_curve(network, ChangeSet(ps))
@app.post("/deletecurve/")
async def fastapi_delete_curve(network: str, curve: str) -> ChangeSet:
ps = { 'id' : curve }
return delete_curve(network, ChangeSet(ps))
@app.get("/getcurveproperties/")
async def fastapi_get_curve_properties(network: str, curve: str) -> dict[str, Any]:
return get_curve(network, curve)
# example: set_curve(p, ChangeSet({'id' : 'c0', 'coords': [{'x': 1.0, 'y': 2.0}, {'x': 2.0, 'y': 1.0}]}))
# example: set_curve(p, ChangeSet({'id' : 'c0', 'c_type' : CURVE_TYPE_PUMP, 'coords': [{'x': 1.0, 'y': 2.0}, {'x': 2.0, 'y': 1.0}]}))
@app.post("/setcurveproperties/")
async def fastapi_set_curve_properties(network: str, curve: str, req: Request) -> ChangeSet:
props = await req.json()
# c_type放到request中
ps = { 'id' : curve } | props
return set_curve(network, ChangeSet(ps))