Add method to get nodes and links
This commit is contained in:
20
main.py
20
main.py
@@ -48,6 +48,16 @@ async def fastapi_create_project(network: str):
|
|||||||
print(network)
|
print(network)
|
||||||
return network
|
return network
|
||||||
|
|
||||||
|
@app.get("/getnodes/")
|
||||||
|
async def fastapi_get_nodes(network: str):
|
||||||
|
nodeCount = get_count(network, NODE_COUNT)
|
||||||
|
nodes = []
|
||||||
|
for i in range(0, nodeCount.value + 1):
|
||||||
|
node_id = get_node_id(network, i)
|
||||||
|
nodes.append(node_id)
|
||||||
|
|
||||||
|
return nodes
|
||||||
|
|
||||||
@app.post("/addnode/")
|
@app.post("/addnode/")
|
||||||
async def fastapi_add_node(network: str, node: str):
|
async def fastapi_add_node(network: str, node: str):
|
||||||
idx = add_node(network, node, JUNCTION)
|
idx = add_node(network, node, JUNCTION)
|
||||||
@@ -70,6 +80,16 @@ async def fastapi_set_node_coord(network: str, node: str, x: int, y: int):
|
|||||||
set_node_coord(network, node, x, y)
|
set_node_coord(network, node, x, y)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@app.get("/getlinks/")
|
||||||
|
async def fastapi_get_links(network: str):
|
||||||
|
linkCount = get_count(network, LINK_COUNT)
|
||||||
|
links = []
|
||||||
|
for i in range(0, linkCount.value + 1):
|
||||||
|
link_id = get_link_id(network, i)
|
||||||
|
links.append(link_id)
|
||||||
|
|
||||||
|
return links
|
||||||
|
|
||||||
@app.post("/addlink/")
|
@app.post("/addlink/")
|
||||||
async def fastapi_add_link(network: str, link: str, fromNode: str, toNode: str):
|
async def fastapi_add_link(network: str, link: str, fromNode: str, toNode: str):
|
||||||
idx = add_link(network, link, PIPE, fromNode, toNode)
|
idx = add_link(network, link, PIPE, fromNode, toNode)
|
||||||
|
|||||||
Reference in New Issue
Block a user