yusufgundogdu commited on
Commit
3197a1a
·
verified ·
1 Parent(s): a37f1b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -12
app.py CHANGED
@@ -1,34 +1,24 @@
1
  from flask import Flask, request, jsonify
2
  import numpy as np
3
 
4
- # Flask-App erstellen
5
  app = Flask(__name__)
6
 
7
  @app.route('/')
8
  def home():
9
  return "stablediffusionapi test"
10
 
11
- @app.route('/predict', methods=['POST']) # WICHTIG: Muss eine POST-Methode sein!
12
  def predict():
13
  try:
14
- # Eingabe als JSON empfangen
15
  data = request.json
16
-
17
- # Falls keine Daten gesendet wurden, Fehler ausgeben
18
  if not data:
19
  return jsonify({"error": "Keine Daten erhalten"}), 400
20
-
21
- # Werte aus JSON extrahieren
22
  X_input = np.array([[data["Open"], data["High"], data["Low"], data["Close"], data["Volume"]]])
23
-
24
- # Dummy-Vorhersage (Zufallswert)
25
  probability = np.random.rand()
26
-
27
  return jsonify({"probability_up": float(probability)})
28
 
29
  except Exception as e:
30
- return jsonify({"error": str(e)}), 500 # Falls ein Fehler auftritt
31
 
32
- # Flask-App starten
33
  if __name__ == '__main__':
34
  app.run(host='0.0.0.0', port=7860)
 
1
  from flask import Flask, request, jsonify
2
  import numpy as np
3
 
 
4
  app = Flask(__name__)
5
 
6
  @app.route('/')
7
  def home():
8
  return "stablediffusionapi test"
9
 
10
+ @app.route('/predict', methods=['POST'])
11
  def predict():
12
  try:
 
13
  data = request.json
 
 
14
  if not data:
15
  return jsonify({"error": "Keine Daten erhalten"}), 400
 
 
16
  X_input = np.array([[data["Open"], data["High"], data["Low"], data["Close"], data["Volume"]]])
 
 
17
  probability = np.random.rand()
 
18
  return jsonify({"probability_up": float(probability)})
19
 
20
  except Exception as e:
21
+ return jsonify({"error": str(e)}), 500
22
 
 
23
  if __name__ == '__main__':
24
  app.run(host='0.0.0.0', port=7860)