23 lines
539 B
Python
23 lines
539 B
Python
import fastapi
|
|
import uvicorn
|
|
|
|
|
|
class ApiManager:
|
|
"""
|
|
Manage the API to have a representation of the device connection
|
|
"""
|
|
|
|
def __init__(self, manager: "Manager"):
|
|
self.manager = manager
|
|
|
|
self.application = fastapi.FastAPI()
|
|
|
|
@self.application.get("/peers")
|
|
async def peers():
|
|
return {
|
|
address
|
|
for address, peer in self.manager.peer.peers.items()
|
|
}
|
|
|
|
def loop(self):
|
|
uvicorn.run(self.application, host="0.0.0.0", port=8000)
|