Skip to content

Commit fb1cc9d

Browse files
committed
viewer: Add HTML helper to view nodes
This is PoC of API viewer for development purposes. Signed-off-by: Denys Fedoryshchenko <[email protected]>
1 parent 628a6d6 commit fb1cc9d

File tree

2 files changed

+428
-0
lines changed

2 files changed

+428
-0
lines changed

api/main.py

+13
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,19 @@ async def stats(user: User = Depends(get_current_superuser)):
713713
"""Get details of all existing subscriptions"""
714714
return await pubsub.subscription_stats()
715715

716+
@app.get('/viewer')
717+
async def viewer():
718+
"""Serve simple HTML page to view the API /static/viewer.html
719+
Set various no-cache tag we might update it often"""
720+
with open('api/viewer.html', 'r') as f:
721+
# set header to text/html and no-cache stuff
722+
hdr = {
723+
'Content-Type': 'text/html',
724+
'Cache-Control': 'no-cache, no-store, must-revalidate',
725+
'Pragma': 'no-cache',
726+
'Expires': '0'
727+
}
728+
return PlainTextResponse(f.read(), headers=hdr)
716729

717730
versioned_app = VersionedFastAPI(
718731
app,

0 commit comments

Comments
 (0)