Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from flask import Flask, render_template, request, redirect, url_for
|
2 |
-
from translation_data import translation_dict_A, translation_dict_B
|
3 |
|
4 |
app = Flask(__name__)
|
5 |
|
@@ -8,8 +8,14 @@ english_sentences_A = list(translation_dict_A.keys())
|
|
8 |
japanese_translations_A = list(translation_dict_A.values())
|
9 |
english_sentences_B = list(translation_dict_B.keys())
|
10 |
japanese_translations_B = list(translation_dict_B.values())
|
|
|
|
|
11 |
|
12 |
@app.route('/')
|
|
|
|
|
|
|
|
|
13 |
def index():
|
14 |
set_name = request.args.get('set', 'A')
|
15 |
index = int(request.args.get('index', 0))
|
@@ -17,10 +23,14 @@ def index():
|
|
17 |
english = english_sentences_A[index]
|
18 |
japanese = japanese_translations_A[index]
|
19 |
total = len(english_sentences_A)
|
20 |
-
|
21 |
english = english_sentences_B[index]
|
22 |
japanese = japanese_translations_B[index]
|
23 |
total = len(english_sentences_B)
|
|
|
|
|
|
|
|
|
24 |
return render_template('index.html', set_name=set_name, index=index, english=english, japanese=japanese, total=total)
|
25 |
|
26 |
@app.route('/next')
|
@@ -31,6 +41,8 @@ def next_card():
|
|
31 |
index = 0
|
32 |
elif set_name == 'B' and index >= len(english_sentences_B):
|
33 |
index = 0
|
|
|
|
|
34 |
return redirect(url_for('index', set=set_name, index=index))
|
35 |
|
36 |
@app.route('/prev')
|
@@ -40,8 +52,10 @@ def prev_card():
|
|
40 |
if index < 0:
|
41 |
if set_name == 'A':
|
42 |
index = len(english_sentences_A) - 1
|
43 |
-
|
44 |
index = len(english_sentences_B) - 1
|
|
|
|
|
45 |
return redirect(url_for('index', set=set_name, index=index))
|
46 |
|
47 |
if __name__ == '__main__':
|
|
|
1 |
from flask import Flask, render_template, request, redirect, url_for
|
2 |
+
from translation_data import translation_dict_A, translation_dict_B, translation_dict_C
|
3 |
|
4 |
app = Flask(__name__)
|
5 |
|
|
|
8 |
japanese_translations_A = list(translation_dict_A.values())
|
9 |
english_sentences_B = list(translation_dict_B.keys())
|
10 |
japanese_translations_B = list(translation_dict_B.values())
|
11 |
+
english_sentences_C = list(translation_dict_C.keys())
|
12 |
+
japanese_translations_C = list(translation_dict_C.values())
|
13 |
|
14 |
@app.route('/')
|
15 |
+
def portal():
|
16 |
+
return render_template('portal.html')
|
17 |
+
|
18 |
+
@app.route('/flashcards')
|
19 |
def index():
|
20 |
set_name = request.args.get('set', 'A')
|
21 |
index = int(request.args.get('index', 0))
|
|
|
23 |
english = english_sentences_A[index]
|
24 |
japanese = japanese_translations_A[index]
|
25 |
total = len(english_sentences_A)
|
26 |
+
elif set_name == 'B':
|
27 |
english = english_sentences_B[index]
|
28 |
japanese = japanese_translations_B[index]
|
29 |
total = len(english_sentences_B)
|
30 |
+
else:
|
31 |
+
english = english_sentences_C[index]
|
32 |
+
japanese = japanese_translations_C[index]
|
33 |
+
total = len(english_sentences_C)
|
34 |
return render_template('index.html', set_name=set_name, index=index, english=english, japanese=japanese, total=total)
|
35 |
|
36 |
@app.route('/next')
|
|
|
41 |
index = 0
|
42 |
elif set_name == 'B' and index >= len(english_sentences_B):
|
43 |
index = 0
|
44 |
+
elif set_name == 'C' and index >= len(english_sentences_C):
|
45 |
+
index = 0
|
46 |
return redirect(url_for('index', set=set_name, index=index))
|
47 |
|
48 |
@app.route('/prev')
|
|
|
52 |
if index < 0:
|
53 |
if set_name == 'A':
|
54 |
index = len(english_sentences_A) - 1
|
55 |
+
elif set_name == 'B':
|
56 |
index = len(english_sentences_B) - 1
|
57 |
+
elif set_name == 'C':
|
58 |
+
index = len(english_sentences_C) - 1
|
59 |
return redirect(url_for('index', set=set_name, index=index))
|
60 |
|
61 |
if __name__ == '__main__':
|