Skip to content

Commit 4bc5f40

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 4bc5f40

File tree

2 files changed

+587
-0
lines changed

2 files changed

+587
-0
lines changed

api/main.py

+17
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,23 @@ async def stats(user: User = Depends(get_current_superuser)):
714714
return await pubsub.subscription_stats()
715715

716716

717+
@app.get('/viewer')
718+
async def viewer():
719+
"""Serve simple HTML page to view the API /static/viewer.html
720+
Set various no-cache tag we might update it often"""
721+
mod_root = os.path.dirname(os.path.abspath(__file__))
722+
viewer_path = os.path.join(mod_root, 'templates', 'viewer.html')
723+
with open(viewer_path, 'r') as file:
724+
# set header to text/html and no-cache stuff
725+
hdr = {
726+
'Content-Type': 'text/html',
727+
'Cache-Control': 'no-cache, no-store, must-revalidate',
728+
'Pragma': 'no-cache',
729+
'Expires': '0'
730+
}
731+
return PlainTextResponse(file.read(), headers=hdr)
732+
733+
717734
versioned_app = VersionedFastAPI(
718735
app,
719736
version_format='{major}',

0 commit comments

Comments
 (0)