50 lines
890 B
Python
50 lines
890 B
Python
import requests
|
|
import logging
|
|
from fastapi import FastAPI
|
|
import uvicorn
|
|
|
|
|
|
import config
|
|
|
|
|
|
logging.basicConfig(level=logging.DEBUG if config.debug ==
|
|
"true" else logging.INFO)
|
|
|
|
print(config.robot_control_server_url)
|
|
|
|
|
|
def InitRobot():
|
|
logging.info("InitRobot")
|
|
|
|
res = requests.post(config.robot_control_server_url + "/robot", json={
|
|
"id": config.robot_id,
|
|
"type": config.robot_type,
|
|
"firmwareVersion": config.robot_firmware_version
|
|
})
|
|
|
|
logging.info(res.status_code)
|
|
|
|
if res.status_code == 403:
|
|
logging.error("Permit join is disabled")
|
|
exit(1)
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"message": "Hello World"}
|
|
|
|
|
|
@app.get("/api/v1/ping")
|
|
async def ping():
|
|
return {"status": "ok"}
|
|
|
|
if __name__ == '__main__':
|
|
logging.info("main")
|
|
|
|
InitRobot()
|
|
|
|
uvicorn.run(app, port=5000)
|