Docfile commited on
Commit
29bfc8e
·
verified ·
1 Parent(s): 2ee54cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py CHANGED
@@ -261,6 +261,44 @@ def generate_dissertation(tableau):
261
  def index():
262
  return render_template('index.html')
263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  @app.route('/analyze', methods=['POST'])
265
  def analyze():
266
  if 'image' not in request.files:
 
261
  def index():
262
  return render_template('index.html')
263
 
264
+ @app.route('/free')
265
+ def free():
266
+ return render_template('free.html')
267
+
268
+ @app.route('/analyzed', methods=['POST'])
269
+ def analyzed():
270
+ if 'image' not in request.files:
271
+ return jsonify({'error': 'No image uploaded'}), 400
272
+
273
+
274
+ image_file = request.files['image']
275
+
276
+ # Sauvegarder temporairement l'image
277
+ with tempfile.NamedTemporaryFile(delete=False) as temp_file:
278
+ image_file.save(temp_file.name)
279
+ image = Image.open(temp_file.name)
280
+
281
+
282
+ try:
283
+ # Première génération : le tableau
284
+ tableau = generate_table(image)
285
+
286
+ # Deuxième génération : la dissertation
287
+ dissertation = generate_dissertation(tableau)
288
+
289
+ return jsonify({
290
+ 'tableau': "error",
291
+ 'dissertation': "error"
292
+ })
293
+ except Exception as e:
294
+ return jsonify({'error': "Erreur."}), 500
295
+ finally:
296
+ # Nettoyer le fichier temporaire
297
+ os.unlink(temp_file.name)
298
+
299
+
300
+
301
+
302
  @app.route('/analyze', methods=['POST'])
303
  def analyze():
304
  if 'image' not in request.files: