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 @@ -733,6 +733,26 @@ async def stats(user: User = Depends(get_current_superuser)):
733
733
return await pubsub .subscription_stats ()
734
734
735
735
736
+ @app .get ('/viewer' )
737
+ async def viewer ():
738
+ """Serve simple HTML page to view the API /static/viewer.html
739
+ Set various no-cache tag we might update it often"""
740
+ mod_root = os .path .dirname (os .path .abspath (__file__ ))
741
+ # truncate the last part of the path to get the root of the module
742
+ # We need to install templates UNDER api package
743
+ mod_root = os .path .dirname (mod_root )
744
+ viewer_path = os .path .join (mod_root , 'templates' , 'viewer.html' )
745
+ with open (viewer_path , 'r' , encoding = 'utf-8' ) as file :
746
+ # set header to text/html and no-cache stuff
747
+ hdr = {
748
+ 'Content-Type' : 'text/html' ,
749
+ 'Cache-Control' : 'no-cache, no-store, must-revalidate' ,
750
+ 'Pragma' : 'no-cache' ,
751
+ 'Expires' : '0'
752
+ }
753
+ return PlainTextResponse (file .read (), headers = hdr )
754
+
755
+
736
756
versioned_app = VersionedFastAPI (
737
757
app ,
738
758
version_format = '{major}' ,
You can’t perform that action at this time.
0 commit comments