Your Name 4 years ago
parent
commit
c005428657
2 changed files with 24 additions and 2 deletions
  1. 2 0
      apis/static/admin.html
  2. 22 2
      apis/testoauth.py

+ 2 - 0
apis/static/admin.html

@@ -351,6 +351,8 @@
                 </nav>
                 <!-- End of Topbar -->
 
+                {{ mycontent |safe}}
+
                 <!-- Begin Page Content -->
                 
 

+ 22 - 2
apis/testoauth.py

@@ -6,8 +6,10 @@ from starlette.middleware.sessions import SessionMiddleware
 from starlette.responses import HTMLResponse, RedirectResponse
 from authlib.integrations.starlette_client import OAuth, OAuthError
 from fastapi.staticfiles import StaticFiles
-import gen_designer_report
+import jinja2
 
+import gen_designer_report
+import os
 app = FastAPI()
 app.add_middleware(SessionMiddleware, secret_key="!secret")
 
@@ -28,6 +30,12 @@ oauth.register(
         'scope': 'openid email profile'
     }
 )
+fname=os.path.abspath(__file__)
+elmts=fname.split(os.path.sep)
+path2=os.path.sep.join(elmts[0:-1])
+keysdir=path2+os.path.sep+'static'+os.path.sep
+templateLoader = jinja2.FileSystemLoader(searchpath=keysdir)
+templateEnv = jinja2.Environment(loader=templateLoader)
 
 
 
@@ -42,12 +50,24 @@ async def homepage(request: Request):
         )
 
         html=gen_designer_report.gen_report()
-        return HTMLResponse(html)
+        TEMPLATE_FILE = "admin.tmpl"
+        template2 = templateEnv.get_template(TEMPLATE_FILE)
+        outputText = template2.render(mycontent=html) 
+        return HTMLResponse(outputText)
+
 #        return HTMLResponse(html)
     return RedirectResponse(url='/static/login.html')
+
+
     #return HTMLResponse('<a href="/login">login</a>')
 
 
+#@app.route('/adm')
+#async def adm(request: Request):
+#    TEMPLATE_FILE = "admin.tmpl"
+#    template = templateEnv.get_template(TEMPLATE_FILE)
+#    outputText = template.render(mycontent=displaydata) 
+
 @app.route('/login')
 async def login(request: Request):
     redirect_uri = request.url_for('auth')