File tree 2 files changed +590
-0
lines changed
2 files changed +590
-0
lines changed Original file line number Diff line number Diff line change @@ -714,6 +714,26 @@ async def stats(user: User = Depends(get_current_superuser)):
714
714
return await pubsub .subscription_stats ()
715
715
716
716
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
+ # truncate the last part of the path to get the root of the module
723
+ # We need to install templates UNDER api package
724
+ mod_root = os .path .dirname (mod_root )
725
+ viewer_path = os .path .join (mod_root , 'templates' , 'viewer.html' )
726
+ with open (viewer_path , 'r' , encoding = 'utf-8' ) as file :
727
+ # set header to text/html and no-cache stuff
728
+ hdr = {
729
+ 'Content-Type' : 'text/html' ,
730
+ 'Cache-Control' : 'no-cache, no-store, must-revalidate' ,
731
+ 'Pragma' : 'no-cache' ,
732
+ 'Expires' : '0'
733
+ }
734
+ return PlainTextResponse (file .read (), headers = hdr )
735
+
736
+
717
737
versioned_app = VersionedFastAPI (
718
738
app ,
719
739
version_format = '{major}' ,
You can’t perform that action at this time.
0 commit comments