Add house sorting algorithm

This commit is contained in:
Sauer 2019-04-14 01:01:22 +02:00
parent 03bba3fc64
commit daac267b64
2 changed files with 12 additions and 1 deletions

View File

@ -71,6 +71,13 @@ def index():
@app.route('/questions', methods=['GET', 'POST'])
def questions():
form = QuestionForm(request.form)
houses = dict()
houses[0] = 'knuth'
houses[1] = 'lovelace'
houses[2] = 'turing'
houses[4] = 'hopper'
houses[8] = 'lamarr'
if request.method == 'POST' and form.validate():
with open(datafile, "a", newline='') as f:
new_row = list()
@ -81,7 +88,9 @@ def questions():
if len(new_row) == 6:
new_row.append('n')
magical_house_number = int(new_row[2]) % 10
new_row.append(houses[magical_house_number])
writer = csv.writer(f)
writer.writerow(new_row)

View File

@ -10,6 +10,7 @@
<th>spirit_animal</th>
<th>operating_system</th>
<th>check</th>
<th>house</th>
</tr>
{% for row in file_data %}
<tr>
@ -20,6 +21,7 @@
<th>{{ row[4] }}</th>
<th>{{ row[5] }}</th>
<th>{{ row[6] }}</th>
<th>{{ row[7] }}</th>
</tr>
{% endfor %}
</table>