bram4627 commited on
Commit
e39e9ae
1 Parent(s): d332fef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -12,9 +12,9 @@ model_load = load_model('lstm_model.h5')
12
  scaler_load = joblib.load('scaler.sav') # Load the correct scaler
13
 
14
  # Flask app initialization
15
- app = Flask(__name__)
16
- app.config["SECRET_KEY"] = os.urandom(24)
17
- app.config["DEBUG"] = True
18
 
19
  def validasi_inputan(form_data):
20
  errors = {}
@@ -51,7 +51,7 @@ def validate_data(record):
51
 
52
  return errors
53
 
54
- @app.route("/", methods=["GET", "POST"])
55
  def index():
56
  prediction = None
57
  errors = {}
@@ -96,12 +96,10 @@ def index():
96
  # Update input dengan prediksi terbaru
97
  last_input_scaled = np.append(last_input_scaled[1:], prediction_normalized, axis=0)
98
 
99
-
100
-
101
  return render_template('index.html', prediction=predictions_list, errors=errors, record=request.form)
102
 
103
  # FastAPI app to mount Flask app
104
- app = FastAPI()
105
 
106
  # Mount Flask app inside FastAPI using WSGIMiddleware
107
- app.mount("/", WSGIMiddleware(app))
 
12
  scaler_load = joblib.load('scaler.sav') # Load the correct scaler
13
 
14
  # Flask app initialization
15
+ flask_app = Flask(__name__)
16
+ flask_app.config["SECRET_KEY"] = os.urandom(24)
17
+ flask_app.config["DEBUG"] = True
18
 
19
  def validasi_inputan(form_data):
20
  errors = {}
 
51
 
52
  return errors
53
 
54
+ @flask_app.route("/", methods=["GET", "POST"])
55
  def index():
56
  prediction = None
57
  errors = {}
 
96
  # Update input dengan prediksi terbaru
97
  last_input_scaled = np.append(last_input_scaled[1:], prediction_normalized, axis=0)
98
 
 
 
99
  return render_template('index.html', prediction=predictions_list, errors=errors, record=request.form)
100
 
101
  # FastAPI app to mount Flask app
102
+ fastapi_app = FastAPI()
103
 
104
  # Mount Flask app inside FastAPI using WSGIMiddleware
105
+ fastapi_app.mount("/", WSGIMiddleware(flask_app))