diff --git a/app.py b/app.py index ce7d7f39f6da29c212c2887037938f32b743bd56..4d208cab6f55736514b69cda7b1916ebd595ce2c 100644 --- a/app.py +++ b/app.py @@ -122,7 +122,7 @@ def url_who_tasks(): page_info=page_info) -@app.route('/who/imported/page/<int:page>') +@app.route('/who/imported/page/<uuid:page>') @app.route('/who/imported') def url_who_imported(page=1): page_info = ApplicationPage('WHO', "Last Import") @@ -137,7 +137,7 @@ def url_who_imported(page=1): page_info=page_info) -@app.route('/who/date_reported/all/page/<int:page>') +@app.route('/who/date_reported/all/page/<uuid:page>') @app.route('/who/date_reported/all') def url_who_date_reported_all(page=1): page_info = ApplicationPage('WHO', "Date Reported", "All") @@ -152,8 +152,8 @@ def url_who_date_reported_all(page=1): page_info=page_info) -@app.route('/who/date_reported/<int:date_reported_id>/page/<int:page>') -@app.route('/who/date_reported/<int:date_reported_id>') +@app.route('/who/date_reported/<uuid:date_reported_id>/page/<uuid:page>') +@app.route('/who/date_reported/<uuid:date_reported_id>') def url_who_date_reported(date_reported_id, page=1): date_reported = WhoDateReported.get_by_id(date_reported_id) page_info = ApplicationPage( @@ -173,8 +173,8 @@ def url_who_date_reported(date_reported_id, page=1): page_info=page_info) -@app.route('/who/date_reported/<int:date_reported_id>/cases_new/page/<int:page>') -@app.route('/who/date_reported/<int:date_reported_id>/cases_new') +@app.route('/who/date_reported/<uuid:date_reported_id>/cases_new/page/<uuid:page>') +@app.route('/who/date_reported/<uuid:date_reported_id>/cases_new') def url_who_date_reported_cases_new(date_reported_id, page=1): date_reported = WhoDateReported.get_by_id(date_reported_id) page_info = ApplicationPage( @@ -194,8 +194,8 @@ def url_who_date_reported_cases_new(date_reported_id, page=1): page_info=page_info) -@app.route('/who/date_reported/<int:date_reported_id>/cases_cumulative/page/<int:page>') -@app.route('/who/date_reported/<int:date_reported_id>/cases_cumulative') +@app.route('/who/date_reported/<uuid:date_reported_id>/cases_cumulative/page/<uuid:page>') +@app.route('/who/date_reported/<uuid:date_reported_id>/cases_cumulative') def url_who_date_reported_cases_cumulative(date_reported_id, page=1): date_reported = WhoDateReported.get_by_id(date_reported_id) page_info = ApplicationPage( @@ -215,8 +215,8 @@ def url_who_date_reported_cases_cumulative(date_reported_id, page=1): page_info=page_info) -@app.route('/who/date_reported/<int:date_reported_id>/deaths_new/page/<int:page>') -@app.route('/who/date_reported/<int:date_reported_id>/deaths_new') +@app.route('/who/date_reported/<uuid:date_reported_id>/deaths_new/page/<uuid:page>') +@app.route('/who/date_reported/<uuid:date_reported_id>/deaths_new') def url_who_date_reported_deaths_new(date_reported_id, page=1): date_reported = WhoDateReported.get_by_id(date_reported_id) page_info = ApplicationPage( @@ -236,8 +236,8 @@ def url_who_date_reported_deaths_new(date_reported_id, page=1): page_info=page_info) -@app.route('/who/date_reported/<int:date_reported_id>/deaths_cumulative/page/<int:page>') -@app.route('/who/date_reported/<int:date_reported_id>/deaths_cumulative') +@app.route('/who/date_reported/<uuid:date_reported_id>/deaths_cumulative/page/<uuid:page>') +@app.route('/who/date_reported/<uuid:date_reported_id>/deaths_cumulative') def url_who_date_reported_deaths_cumulative(date_reported_id, page=1): date_reported = WhoDateReported.get_by_id(date_reported_id) page_info = ApplicationPage( @@ -257,7 +257,7 @@ def url_who_date_reported_deaths_cumulative(date_reported_id, page=1): page_info=page_info) -@app.route('/who/region/all/page/<int:page>') +@app.route('/who/region/all/page/<uuid:page>') @app.route('/who/region/all') def url_who_region_all(page=1): page_info = ApplicationPage('WHO', "Region", "All") @@ -272,8 +272,8 @@ def url_who_region_all(page=1): page_info=page_info) -@app.route('/who/region/<int:region_id>/page/<int:page>') -@app.route('/who/region/<int:region_id>') +@app.route('/who/region/<uuid:region_id>/page/<uuid:page>') +@app.route('/who/region/<uuid:region_id>') def url_who_region(region_id, page=1): who_region = None page_info = ApplicationPage("Countries", "WHO Region") @@ -293,7 +293,7 @@ def url_who_region(region_id, page=1): page_info=page_info) -@app.route('/who/country/all/page/<int:page>') +@app.route('/who/country/all/page/<uuid:page>') @app.route('/who/country/all') def url_who_country_all(page=1): page_info = ApplicationPage('WHO', "Countries", "All") @@ -308,8 +308,8 @@ def url_who_country_all(page=1): page_info=page_info) -@app.route('/who/country/<int:country_id>/page/<int:page>') -@app.route('/who/country/<int:country_id>') +@app.route('/who/country/<uuid:country_id>/page/<uuid:page>') +@app.route('/who/country/<uuid:country_id>') def url_who_country(country_id, page=1): who_country = WhoCountry.get_by_id(country_id) page_data = WhoGlobalData.get_data_for_country(who_country, page) @@ -323,8 +323,8 @@ def url_who_country(country_id, page=1): page_info=page_info) -@app.route('/who/country/<int:country_id>/cases_new/page/<int:page>') -@app.route('/who/country/<int:country_id>/cases_new') +@app.route('/who/country/<uuid:country_id>/cases_new/page/<uuid:page>') +@app.route('/who/country/<uuid:country_id>/cases_new') def url_who_country_cases_new(country_id, page=1): who_country = WhoCountry.get_by_id(country_id) page_data = WhoGlobalData.get_data_for_country_order_by_cases_new(who_country, page) @@ -338,8 +338,8 @@ def url_who_country_cases_new(country_id, page=1): page_info=page_info) -@app.route('/who/country/<int:country_id>/cases_cumulative/page/<int:page>') -@app.route('/who/country/<int:country_id>/cases_cumulative') +@app.route('/who/country/<uuid:country_id>/cases_cumulative/page/<uuid:page>') +@app.route('/who/country/<uuid:country_id>/cases_cumulative') def url_who_country_cases_cumulative(country_id, page=1): who_country = WhoCountry.get_by_id(country_id) page_data = WhoGlobalData.get_data_for_country_order_by_cases_cumulative(who_country, page) @@ -353,8 +353,8 @@ def url_who_country_cases_cumulative(country_id, page=1): page_info=page_info) -@app.route('/who/country/<int:country_id>/deaths_new/page/<int:page>') -@app.route('/who/country/<int:country_id>/deaths_new') +@app.route('/who/country/<uuid:country_id>/deaths_new/page/<uuid:page>') +@app.route('/who/country/<uuid:country_id>/deaths_new') def url_who_country_deaths_new(country_id, page=1): who_country = WhoCountry.get_by_id(country_id) page_data = WhoGlobalData.get_data_for_country_order_by_deaths_new(who_country, page) @@ -368,8 +368,8 @@ def url_who_country_deaths_new(country_id, page=1): page_info=page_info) -@app.route('/who/country/<int:country_id>/deaths_cumulative/page/<int:page>') -@app.route('/who/country/<int:country_id>/deaths_cumulative') +@app.route('/who/country/<uuid:country_id>/deaths_cumulative/page/<uuid:page>') +@app.route('/who/country/<uuid:country_id>/deaths_cumulative') def url_who_country_deaths_cumulative(country_id, page=1): who_country = WhoCountry.get_by_id(country_id) page_data = WhoGlobalData.get_data_for_country_order_by_deaths_cumulative(who_country, page) @@ -383,7 +383,7 @@ def url_who_country_deaths_cumulative(country_id, page=1): page_info=page_info) -@app.route('/who/germany/page/<int:page>') +@app.route('/who/germany/page/<uuid:page>') @app.route('/who/germany') def url_who_germany(page=1): page_info = ApplicationPage('WHO', "Germany") diff --git a/database.py b/database.py index 92f2a1d2de983288e7ad4257b54093925427b05e..0e3467039489648ddfe6d022db7f5a36f7a81100 100644 --- a/database.py +++ b/database.py @@ -1,8 +1,11 @@ from flask import Flask from flask_cors import CORS from flask_sqlalchemy import SQLAlchemy +from flask_uuid import FlaskUUID + app = Flask('app') +FlaskUUID(app) CORS(app) app.config.from_object("config") ITEMS_PER_PAGE = app.config['ITEMS_PER_PAGE'] diff --git a/requirements.txt b/requirements.txt index 5b19c52b8593ef292fcd271297758e56a3759d21..cb7d7d8106e590f62a09edf69f13fd897b7ee391 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ packaging==20.8 Flask==1.1.2 Flask-DB==0.3.0 Flask-SQLAlchemy==2.4.4 +Flask-UUID==0.2 SQLAlchemy==1.3.22 SQLAlchemy-Utils==0.36.8 Jinja2==2.11.2