File size: 1,446 Bytes
0eae3d6
fe5005f
e218737
c3883a9
de7e336
c3883a9
fe5005f
 
c3883a9
 
e218737
 
 
fe5005f
 
 
 
 
 
 
 
 
 
 
 
0eae3d6
 
fe5005f
c3883a9
e218737
 
 
c3883a9
fe5005f
 
 
c3883a9
e218737
fe5005f
 
 
 
 
 
 
 
e218737
 
fe5005f
612150f
e218737
fe5005f
 
0eae3d6
612150f
 
fe5005f
ef81ad8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from flask import Flask, render_template, redirect, url_for, request
import csv
import requests
import os
from dotenv import load_dotenv

load_dotenv()

app = Flask(__name__)

# Configuration Telegram


# Chargement du dataset de traductions
def load_translations(filename):
    translations = []
    with open(filename, 'r', encoding='utf-8') as file:
        reader = csv.DictReader(file)
        for i, row in enumerate(reader):
            translations.append({
                "id": i,
                "fr": row["fr"],
                "yi": row["yi"],
                "likes": 0,
                "dislikes": 0,
                "feedback_sent": False
            })
    return translations


translations = load_translations('translations.csv')


@app.route('/')
def index():
    return render_template('index.html', translations=translations)


@app.route('/vote/<int:id>/<string:action>')
def vote(id, action):
    translation = next((t for t in translations if t["id"] == id), None)
    if translation:
        if action == "like":
            translation["likes"] += 1
        elif action == "dislike":
            translation["dislikes"] += 1
        elif action == "submit":
           translation["feedback_sent"] = True
    return redirect(url_for('index'))


@app.route('/submit_feedback/<int:id>', methods=['POST'])
def submit_feedback(id):
     return redirect(url_for('index'))


if __name__ == '__main__':
    app.run(debug=True)