JSON Response fixed

This commit is contained in:
Andreas 2024-10-09 12:33:00 +02:00 committed by Andreas
parent 4284119352
commit 7b05fc04ce
2 changed files with 11 additions and 3 deletions

View File

@ -142,7 +142,13 @@ class EnergieManagementSystem:
keys_to_modify = [
"Last_Wh_pro_Stunde",
"Netzeinspeisung_Wh_pro_Stunde",
"akku_soc_pro_stunde",
"Netzbezug_Wh_pro_Stunde",
"Kosten_Euro_pro_Stunde",
"Einnahmen_Euro_pro_Stunde",
"E-Auto_SoC_pro_Stunde",
"Verluste_Pro_Stunde",
"Haushaltsgeraet_wh_pro_stunde"
]
# Loop through each key in the list

View File

@ -3,14 +3,14 @@
import os
from datetime import datetime
from typing import Any, TypeGuard
import json
import matplotlib
# Sets the Matplotlib backend to 'Agg' for rendering plots in environments without a display
matplotlib.use("Agg")
import pandas as pd
from flask import Flask, jsonify, redirect, request, send_from_directory, url_for
from flask import Flask, jsonify, redirect, request, send_from_directory, url_for, Response
from akkudoktoreos.class_load import LoadForecast
from akkudoktoreos.class_load_container import Gesamtlast
@ -252,7 +252,9 @@ def flask_optimize():
if "min_soc_prozent" not in parameter:
parameter["min_soc_prozent"] = None
return jsonify(result) # Return optimization results as JSON
# convert to JSON (None accepted by dumps)
json_data = json.dumps(result)
return Response(json_data, mimetype='application/json')
@app.route("/visualisierungsergebnisse.pdf")