Docfile commited on
Commit
e218737
·
verified ·
1 Parent(s): 8bd71a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -1,5 +1,6 @@
1
  from flask import Flask, render_template, redirect, url_for, request
2
  import csv
 
3
  import os
4
  from dotenv import load_dotenv
5
 
@@ -7,6 +8,9 @@ load_dotenv()
7
 
8
  app = Flask(__name__)
9
 
 
 
 
10
  # Chargement du dataset de traductions
11
  def load_translations(filename):
12
  translations = []
@@ -23,12 +27,15 @@ def load_translations(filename):
23
  })
24
  return translations
25
 
26
- translations = load_translations('translations.csv') # Votre dataset au format csv
 
 
27
 
28
  @app.route('/')
29
  def index():
30
  return render_template('index.html', translations=translations)
31
 
 
32
  @app.route('/vote/<int:id>/<string:action>')
33
  def vote(id, action):
34
  translation = next((t for t in translations if t["id"] == id), None)
@@ -37,10 +44,11 @@ def vote(id, action):
37
  translation["likes"] += 1
38
  elif action == "dislike":
39
  translation["dislikes"] += 1
40
- elif action == "submit":
41
- translation["feedback_sent"] = True
42
  return redirect(url_for('index'))
43
 
 
44
  @app.route('/submit_feedback/<int:id>', methods=['POST'])
45
  def submit_feedback(id):
46
  return redirect(url_for('index'))
 
1
  from flask import Flask, render_template, redirect, url_for, request
2
  import csv
3
+ import requests
4
  import os
5
  from dotenv import load_dotenv
6
 
 
8
 
9
  app = Flask(__name__)
10
 
11
+ # Configuration Telegram
12
+
13
+
14
  # Chargement du dataset de traductions
15
  def load_translations(filename):
16
  translations = []
 
27
  })
28
  return translations
29
 
30
+
31
+ translations = load_translations('translations.csv')
32
+
33
 
34
  @app.route('/')
35
  def index():
36
  return render_template('index.html', translations=translations)
37
 
38
+
39
  @app.route('/vote/<int:id>/<string:action>')
40
  def vote(id, action):
41
  translation = next((t for t in translations if t["id"] == id), None)
 
44
  translation["likes"] += 1
45
  elif action == "dislike":
46
  translation["dislikes"] += 1
47
+ elif action == "submit":
48
+ translation["feedback_sent"] = True
49
  return redirect(url_for('index'))
50
 
51
+
52
  @app.route('/submit_feedback/<int:id>', methods=['POST'])
53
  def submit_feedback(id):
54
  return redirect(url_for('index'))