# @author: Simon Bowie <ad7588@coventry.ac.uk> | # @author: Simon Bowie <ad7588@coventry.ac.uk> | ||||
# @purpose: data route for data | # @purpose: data route for data | ||||
# @acknowledgements: | # @acknowledgements: | ||||
# | |||||
# pycountry module for country data | |||||
from flask import Blueprint, render_template, request | from flask import Blueprint, render_template, request | ||||
import random | import random | ||||
if country is None: | if country is None: | ||||
country = pycountry.historic_countries.get(alpha_2=country_data[i]) | country = pycountry.historic_countries.get(alpha_2=country_data[i]) | ||||
country_labels.append(country.name) | country_labels.append(country.name) | ||||
country_data[i] = country | |||||
country_dataset.append(country_dict) | country_dataset.append(country_dict) | ||||
germany = pycountry.countries.get(alpha_2='DE') | germany = pycountry.countries.get(alpha_2='DE') |
</p> | </p> | ||||
{% endif %} | {% endif %} | ||||
{% if result['country'] is defined %} | |||||
<p class="mb-2"> | |||||
Country: | |||||
{{ result['country'].name }} | |||||
{{ result['country'].flag }} | |||||
</p> | |||||
{% endif %} | |||||
{% if result['original_title'] is defined %} | {% if result['original_title'] is defined %} | ||||
<p class="mb-2"> | <p class="mb-2"> | ||||
Original language title: | Original language title: |
<br><br> | <br><br> | ||||
<div class="row"> | |||||
<div class="col-6 text-center"> | |||||
{% for i in range(0, year_data|length) %} | |||||
{% if i % 2 %} | |||||
{{ year_data[i] }}<br> | |||||
{% else %} | |||||
{{ year_data[i] }}: | |||||
{% endif %} | |||||
{% endfor %} | |||||
</div> | |||||
<div class="col-6 text-center"> | |||||
{% for i in range(0, country_data|length) %} | |||||
{% if i % 2 %} | |||||
{{ country_data[i] }}<br> | |||||
{% else %} | |||||
{{ country_data[i].name }} {{ country_data[i].flag }}: | |||||
{% endif %} | |||||
{% endfor %} | |||||
</div> | |||||
</div> | |||||
<canvas id="chartOfYearFrequency" width="600" height="300"></canvas> | <canvas id="chartOfYearFrequency" width="600" height="300"></canvas> | ||||
<canvas id="chartOfCountryFrequency" width="600" height="300"></canvas> | <canvas id="chartOfCountryFrequency" width="600" height="300"></canvas> | ||||