This commit is contained in:
Wolfgang Hottgenroth 2025-01-21 17:29:58 +01:00
parent 36739a16a6
commit c54db7b820
Signed by: wn
GPG Key ID: 18FDFA577A8871AD
2 changed files with 30 additions and 2 deletions

View File

@ -11,15 +11,18 @@ Flask==3.1.0
flask-oidc==2.2.2
Flask-Session==0.8.0
idna==3.10
importlib_metadata==8.5.0
importlib_metadata==8.6.1
itsdangerous==2.2.0
Jinja2==3.1.5
loguru==0.7.3
MarkupSafe==3.0.2
msgspec==0.19.0
packaging==24.2
plotly==5.24.1
pycparser==2.22
redis==5.2.1
requests==2.32.3
tenacity==9.0.0
urllib3==2.3.0
Werkzeug==3.1.3
zipp==3.21.0

View File

@ -1,9 +1,10 @@
from flask import Flask, session, g
from flask import Flask, session, g, render_template_string
from flask_session import Session
from flask_oidc import OpenIDConnect
from loguru import logger
import redis
import os
import plotly.graph_objects as go
try:
redis_url = os.environ['REDIS_URL']
@ -48,5 +49,29 @@ def index():
session['counter'] = f"{counter}"
return f"Hello, Flask! Called for the {counter}. time."
@app.route('/plot')
@oidc.require_login
def plot():
fig1 = go.Figure(data=[go.Scatter(x=[1, 2, 3], y=[4, 1, 6], mode='lines+markers')])
graph_html_1 = fig1.to_html(full_html=False) # Nur das Diagramm-HTML
fig2 = go.Figure(data=[go.Scatter(x=[1, 2, 3], y=[1, 1, 2], mode='lines+markers')])
graph_html_2 = fig2.to_html(full_html=False) # Nur das Diagramm-HTML
# Diagramm in eine HTML-Seite einbetten
return render_template_string(f"""
<html>
<head>
<title>Plotly ohne Dash</title>
</head>
<body>
<h1>Plotly-Diagramm 1</h1>
{graph_html_1}
<h1>Plotly-Diagramm 2</h1>
{graph_html_2}
</body>
</html>
""")
if __name__ == '__main__':
app.run(port=8080)