21 lines
409 B
Python
21 lines
409 B
Python
from fastapi import FastAPI, Request
|
|
import uvicorn
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/")
|
|
def read_root():
|
|
return {"message": "Server is running!"}
|
|
|
|
|
|
@app.post("/")
|
|
async def receive_data(request: Request):
|
|
data = await request.body()
|
|
str_data = data.decode('utf-8')
|
|
print(str_data)
|
|
return {"received_data": str_data}
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|