Compare commits

...

3 Commits

7 changed files with 17 additions and 12 deletions

View File

@ -4,14 +4,14 @@ from typing import List
from bs4 import BeautifulSoup
from requests import get
from constants import FLICKR_URL, URL
from constants import FLICKR_URL, DATASET_URL
def format_url(dataset) -> str:
"""
Constructs the API's URL for the requested dataset
"""
link = URL.format(dataset)
link = DATASET_URL.format(dataset)
return link

View File

@ -21,5 +21,6 @@ def create_map(df):
"""
m = Map(location=COORDINATES, zoom_start=12)
for index, row in df.iterrows():
Marker(location=row["fields.geo_shape.coordinates"]).add_to(m)
lng, lat = row["fields.geo_shape.coordinates"]
Marker(location=[lat, lng]).add_to(m)
m.save("app/templates/map.html")

View File

@ -3,7 +3,7 @@ from app.preprocessing import create_dataframe, create_map
def create_table(df) -> str:
df.fillna(value=0, inplace=True)
table = df.to_html(classes=["table-striped", "table-hover"])
table = df.to_html(classes=["table-striped", "table-sm", "table-responsive"])
return table

View File

@ -33,5 +33,5 @@ def map():
@app.route("/photos")
def photos():
images = scrape_flickr("paris")
images = scrape_flickr("paris coronavirus")
return render_template("photos.html", title="Photos", images=images)

View File

@ -3,9 +3,13 @@
{% block app_content %}
<h1>Dataset visualization</h1>
<iframe class="map", src="/map" width="400" height="400"></iframe>
<table style="margin-left: 350px;">
{{ table|safe }}
</table>
<div class="row">
<div class="col-md-9">
{{ table|safe }}
</div>
<div class="col-md-1">
<iframe class="map", src="/map" width="350" height="350"></iframe>
</div>
</div>
<p><a href="{{ url_for('data') }}">Back</a></p>
{% endblock %}

View File

@ -4,7 +4,7 @@ DATASETS = [
"deconfinement-parking-relais-doublement-des-places",
"deconfinement-rues-amenagees-pour-pietons",
]
URL = "https://opendata.paris.fr/api/records/1.0/search/?dataset={}&q=&rows=-1"
DATASET_URL = "https://opendata.paris.fr/api/records/1.0/search/?dataset={}&q=&rows=-1"
FLICKR_URL = "https://www.flickr.com/search/?text={}"
COLUMNS = {
"deconfinement-pistes-cyclables-temporaires": [

View File

@ -3,7 +3,7 @@ from requests import get
from app.preprocessing import create_dataframe
from app.data_request import request_dataset
from constants import COLUMNS, DATASETS, URL
from constants import COLUMNS, DATASETS, DATASET_URL
def test_dataset_request():
@ -11,7 +11,7 @@ def test_dataset_request():
Checks that the datasets URLs are reachable
"""
for dataset in DATASETS:
response = get(URL.format(dataset))
response = get(DATASET_URL.format(dataset))
assert response.status_code == 200