Spaces:
Paused
Paused
giorgio-caparvi
commited on
Commit
·
cea6160
1
Parent(s):
98777c8
added post test method
Browse files- api/app.py +15 -1
api/app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from flask import Flask, render_template, send_from_directory, send_file, request
|
2 |
from flask_cors import CORS
|
3 |
import subprocess
|
4 |
import os
|
@@ -92,6 +92,20 @@ def generate_design():
|
|
92 |
except Exception as e:
|
93 |
print(f"### Errore globale: {str(e)} ###") # Stampa per il debug
|
94 |
return str(e), 500
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
if __name__ == '__main__':
|
97 |
app.run(host='0.0.0.0', port=7860, debug=True)
|
|
|
1 |
+
from flask import Flask, render_template, send_from_directory, send_file, request, jsonify
|
2 |
from flask_cors import CORS
|
3 |
import subprocess
|
4 |
import os
|
|
|
92 |
except Exception as e:
|
93 |
print(f"### Errore globale: {str(e)} ###") # Stampa per il debug
|
94 |
return str(e), 500
|
95 |
+
|
96 |
+
@app.route('/test_post', methods=['POST'])
|
97 |
+
def test_post():
|
98 |
+
# Verifica se la richiesta è POST
|
99 |
+
if request.method == 'POST':
|
100 |
+
# Ottieni i dati dal corpo della richiesta
|
101 |
+
data = request.get_json()
|
102 |
+
|
103 |
+
# Se i dati non sono presenti o il formato non è corretto
|
104 |
+
if not data:
|
105 |
+
return jsonify({'message': 'Nessun dato ricevuto o dati non validi'}), 400
|
106 |
+
|
107 |
+
# Restituisci una risposta con i dati ricevuti
|
108 |
+
return jsonify({'message': 'POST funzionante', 'data_received': data}), 200
|
109 |
|
110 |
if __name__ == '__main__':
|
111 |
app.run(host='0.0.0.0', port=7860, debug=True)
|