Skip to content

Commit

Permalink
viewer: Add HTML helper to view nodes
Browse files Browse the repository at this point in the history
This is PoC of API viewer for development purposes.

Signed-off-by: Denys Fedoryshchenko <[email protected]>
  • Loading branch information
nuclearcat committed Jan 25, 2024
1 parent 628a6d6 commit 92b1cf3
Show file tree
Hide file tree
Showing 2 changed files with 430 additions and 0 deletions.
15 changes: 15 additions & 0 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,21 @@ async def stats(user: User = Depends(get_current_superuser)):
return await pubsub.subscription_stats()


@app.get('/viewer')
async def viewer():
"""Serve simple HTML page to view the API /static/viewer.html
Set various no-cache tag we might update it often"""
with open('api/viewer.html', 'r', encoding='utf-8') as file:
# set header to text/html and no-cache stuff
hdr = {
'Content-Type': 'text/html',
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0'
}
return PlainTextResponse(file.read(), headers=hdr)


versioned_app = VersionedFastAPI(
app,
version_format='{major}',
Expand Down
Loading

0 comments on commit 92b1cf3

Please sign in to comment.