OzoneAsai commited on
Commit
518eeee
1 Parent(s): 4400e3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
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, translation_dict_C
3
 
4
  app = Flask(__name__)
5
 
@@ -10,6 +10,8 @@ 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():
@@ -27,10 +29,14 @@ def index():
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')
@@ -43,6 +49,8 @@ def next_card():
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')
@@ -56,6 +64,8 @@ def prev_card():
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__':
 
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, translation_dict_D
3
 
4
  app = Flask(__name__)
5
 
 
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
+ english_sentences_D = list(translation_dict_D.keys())
14
+ japanese_translations_D = list(translation_dict_D.values())
15
 
16
  @app.route('/')
17
  def portal():
 
29
  english = english_sentences_B[index]
30
  japanese = japanese_translations_B[index]
31
  total = len(english_sentences_B)
32
+ elif set_name == 'C':
33
  english = english_sentences_C[index]
34
  japanese = japanese_translations_C[index]
35
  total = len(english_sentences_C)
36
+ elif set_name == 'D':
37
+ english = english_sentences_D[index]
38
+ japanese = japanese_translations_D[index]
39
+ total = len(english_sentences_D)
40
  return render_template('index.html', set_name=set_name, index=index, english=english, japanese=japanese, total=total)
41
 
42
  @app.route('/next')
 
49
  index = 0
50
  elif set_name == 'C' and index >= len(english_sentences_C):
51
  index = 0
52
+ elif set_name == 'D' and index >= len(english_sentences_D):
53
+ index = 0
54
  return redirect(url_for('index', set=set_name, index=index))
55
 
56
  @app.route('/prev')
 
64
  index = len(english_sentences_B) - 1
65
  elif set_name == 'C':
66
  index = len(english_sentences_C) - 1
67
+ elif set_name == 'D':
68
+ index = len(english_sentences_D) - 1
69
  return redirect(url_for('index', set=set_name, index=index))
70
 
71
  if __name__ == '__main__':