allow setting custom port

This commit is contained in:
Daniel Molkentin 2024-09-10 17:17:49 +02:00
parent c52340d9cb
commit 7c6a8515c6

9
flask_server.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
from flask import Flask, jsonify, request
import numpy as np
from modules.class_load import *
@ -325,11 +326,15 @@ def get_pdf():
if __name__ == '__main__':
app.run(debug=True, host="0.0.0.0")
try:
port = os.getenv("FLASK_RUN_PORT", 5000)
app.run(debug=True, host="0.0.0.0", port=port)
except:
print(f"Coud not bind to port {port}, set FLASK_RUN_PORT.")
# PV Forecast:
# object {
# pvpower: array[48]
# temperature: array[48]
# }
# }