Compare commits
3 Commits
ec1729e92c
...
8307a54fe0
Author | SHA1 | Date | |
---|---|---|---|
8307a54fe0 | |||
da4d9b1dad | |||
b33c6991e9 |
@ -4,14 +4,14 @@ from typing import List
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from requests import get
|
from requests import get
|
||||||
|
|
||||||
from constants import FLICKR_URL, URL
|
from constants import FLICKR_URL, DATASET_URL
|
||||||
|
|
||||||
|
|
||||||
def format_url(dataset) -> str:
|
def format_url(dataset) -> str:
|
||||||
"""
|
"""
|
||||||
Constructs the API's URL for the requested dataset
|
Constructs the API's URL for the requested dataset
|
||||||
"""
|
"""
|
||||||
link = URL.format(dataset)
|
link = DATASET_URL.format(dataset)
|
||||||
return link
|
return link
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,5 +21,6 @@ def create_map(df):
|
|||||||
"""
|
"""
|
||||||
m = Map(location=COORDINATES, zoom_start=12)
|
m = Map(location=COORDINATES, zoom_start=12)
|
||||||
for index, row in df.iterrows():
|
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")
|
m.save("app/templates/map.html")
|
||||||
|
@ -3,7 +3,7 @@ from app.preprocessing import create_dataframe, create_map
|
|||||||
|
|
||||||
def create_table(df) -> str:
|
def create_table(df) -> str:
|
||||||
df.fillna(value=0, inplace=True)
|
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
|
return table
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,5 +33,5 @@ def map():
|
|||||||
|
|
||||||
@app.route("/photos")
|
@app.route("/photos")
|
||||||
def photos():
|
def photos():
|
||||||
images = scrape_flickr("paris")
|
images = scrape_flickr("paris coronavirus")
|
||||||
return render_template("photos.html", title="Photos", images=images)
|
return render_template("photos.html", title="Photos", images=images)
|
||||||
|
@ -3,9 +3,13 @@
|
|||||||
|
|
||||||
{% block app_content %}
|
{% block app_content %}
|
||||||
<h1>Dataset visualization</h1>
|
<h1>Dataset visualization</h1>
|
||||||
<iframe class="map", src="/map" width="400" height="400"></iframe>
|
<div class="row">
|
||||||
<table style="margin-left: 350px;">
|
<div class="col-md-9">
|
||||||
{{ table|safe }}
|
{{ table|safe }}
|
||||||
</table>
|
</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>
|
<p><a href="{{ url_for('data') }}">Back</a></p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -4,7 +4,7 @@ DATASETS = [
|
|||||||
"deconfinement-parking-relais-doublement-des-places",
|
"deconfinement-parking-relais-doublement-des-places",
|
||||||
"deconfinement-rues-amenagees-pour-pietons",
|
"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={}"
|
FLICKR_URL = "https://www.flickr.com/search/?text={}"
|
||||||
COLUMNS = {
|
COLUMNS = {
|
||||||
"deconfinement-pistes-cyclables-temporaires": [
|
"deconfinement-pistes-cyclables-temporaires": [
|
||||||
|
@ -3,7 +3,7 @@ from requests import get
|
|||||||
|
|
||||||
from app.preprocessing import create_dataframe
|
from app.preprocessing import create_dataframe
|
||||||
from app.data_request import request_dataset
|
from app.data_request import request_dataset
|
||||||
from constants import COLUMNS, DATASETS, URL
|
from constants import COLUMNS, DATASETS, DATASET_URL
|
||||||
|
|
||||||
|
|
||||||
def test_dataset_request():
|
def test_dataset_request():
|
||||||
@ -11,7 +11,7 @@ def test_dataset_request():
|
|||||||
Checks that the datasets URLs are reachable
|
Checks that the datasets URLs are reachable
|
||||||
"""
|
"""
|
||||||
for dataset in DATASETS:
|
for dataset in DATASETS:
|
||||||
response = get(URL.format(dataset))
|
response = get(DATASET_URL.format(dataset))
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user