Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HITL - Add status API to availability server. #2023

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,24 @@ async def http_handler(request):
# print(f"Returned availability HTTP code {code}")
return aiohttp.web.Response(status=code)

async def get_status(request):
0mdc marked this conversation as resolved.
Show resolved Hide resolved
return aiohttp.web.json_response(
{
"accepting_users": network_mgr.is_server_available(),
"user_count": len(network_mgr._user_slots),
},
text=None,
body=None,
status=200,
0mdc marked this conversation as resolved.
Show resolved Hide resolved
reason=None,
headers=None,
content_type="application/json",
dumps=json.dumps,
)

app = aiohttp.web.Application()
app.router.add_get("/", http_handler)
0mdc marked this conversation as resolved.
Show resolved Hide resolved
app.router.add_get("/status", get_status)
runner = aiohttp.web.AppRunner(
app, access_log=None
) # access_log=None to silence log spam
Expand Down