You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.0 KiB
33 lines
1.0 KiB
from flask import Flask, request, jsonify
|
|
from flask_cors import CORS
|
|
|
|
app = Flask(__name__)
|
|
CORS(app, resources={r"/*": {"origins": "http://resumen-sapian-cctel-02.dialbox.cloud"}})
|
|
|
|
@app.route('/rango_cumplimiento', methods=['POST'])
|
|
def save_compliance_range():
|
|
try:
|
|
# Obtener el texto enviado en la solicitud
|
|
data = request.get_json()
|
|
text = data.get('text')
|
|
|
|
# Validar que el texto no esté vacío
|
|
if not text:
|
|
return jsonify({"error": "El texto no puede estar vacío."}), 400
|
|
|
|
# Ruta del archivo donde se guardará el texto
|
|
file_path = "/home/rango_cumplimiento.txt"
|
|
|
|
# Escribir el texto en el archivo
|
|
with open(file_path, 'w') as file:
|
|
file.write(text)
|
|
|
|
return jsonify({"message": "Texto guardado correctamente en rango_cumplimiento.txt"}), 200
|
|
|
|
except Exception as e:
|
|
return jsonify({"error": "Error al guardar el texto.", "details": str(e)}), 500
|
|
|
|
if __name__ == '__main__':
|
|
app.run(host='0.0.0.0', port=5021)
|
|
|