Add batch
This commit is contained in:
12
main.py
12
main.py
@@ -1,8 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
import io
|
import io
|
||||||
|
import json
|
||||||
from typing import *
|
from typing import *
|
||||||
|
from urllib.request import Request
|
||||||
from fastapi import FastAPI, File, UploadFile
|
from fastapi import FastAPI, File, UploadFile
|
||||||
import pip
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from starlette.responses import FileResponse, JSONResponse
|
from starlette.responses import FileResponse, JSONResponse
|
||||||
from fastapi import FastAPI, Response, status
|
from fastapi import FastAPI, Response, status
|
||||||
@@ -95,6 +96,15 @@ async def fastapi_get_current_operaiton_id(network: str) -> int:
|
|||||||
def fastapi_sync_with_server(network: str, operationid: int) -> ChangeSet:
|
def fastapi_sync_with_server(network: str, operationid: int) -> ChangeSet:
|
||||||
return sync_with_server(network, operationid)
|
return sync_with_server(network, operationid)
|
||||||
|
|
||||||
|
@app.post("/batch/")
|
||||||
|
def fastapi_execute_batch_commands(network: str, request: Request) -> ChangeSet:
|
||||||
|
jsTxt = request.json()
|
||||||
|
joOps = json.loads(jsTxt)['operations']
|
||||||
|
cs:ChangeSet = ChangeSet({})
|
||||||
|
for js in joOps:
|
||||||
|
cs.add(js)
|
||||||
|
return api.execute_batch_commands(network, cs)
|
||||||
|
|
||||||
# node
|
# node
|
||||||
@app.get("/getnodes/")
|
@app.get("/getnodes/")
|
||||||
async def fastapi_get_nodes(network: str) -> list[str]:
|
async def fastapi_get_nodes(network: str) -> list[str]:
|
||||||
|
|||||||
Reference in New Issue
Block a user