You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
719 B
32 lines
719 B
from api_models import API_CORE
|
|
from fastapi import WebSocket
|
|
from time import time
|
|
import asyncio
|
|
|
|
class API_EXTENSION:
|
|
def __init__(self, api):
|
|
self.api: API_CORE = api
|
|
print("PingPong")
|
|
self.response = {
|
|
"ping":"pong",
|
|
"ts": time()
|
|
}
|
|
|
|
def routes(self):
|
|
@self.api.app.get("/api/ping")
|
|
async def call():
|
|
return self.response
|
|
|
|
async def wshello(self, websocket: WebSocket):
|
|
await websocket.send_json({})
|
|
|
|
@property
|
|
def tasks(self):
|
|
async def updateTs():
|
|
while 1:
|
|
self.response["ts"] = time()
|
|
await asyncio.sleep(1)
|
|
|
|
return [updateTs]
|
|
|
|
|