Spaces:
Configuration error
Configuration error
File size: 634 Bytes
8cfbb4d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from fastapi import FastAPI
from fastapi.encoders import jsonable_encoder
app = FastAPI()
global STREAMABLE
STREAMABLE = []
@app.get("/")
def root():
return { "Root" : "Server is up"}
@app.put("/port/append/{stream}")
def push(stream):
try:
streamline = jsonable_encoder(stream)
except E:
return {"appended" : True, "error" : f"{E}"}
STREAMABLE.append(jsonable_encoder(streamline))
return {"appended" : True }
@app.get('/port/open')
def open():
return jsonable_encoder(STREAMABLE)
@app.put('/port/remove/{stream}')
def remove(stream):
STREAMABLE.remove(stream)
return STREAMABLE |