Add photo visualization page
This commit is contained in:
parent
dd7f1bab8d
commit
ec1729e92c
|
@ -37,7 +37,16 @@ def request_flickr(keywords) -> str:
|
||||||
return html
|
return html
|
||||||
|
|
||||||
|
|
||||||
def scrap_flickr(keywords) -> List[str]:
|
def extract_urls(images):
|
||||||
|
"""
|
||||||
|
Creates proper URLs from the regex matches
|
||||||
|
"""
|
||||||
|
links = findall("(live.staticflickr.com/\S+.jpg)", str(images))
|
||||||
|
formatted_urls = ["https://" + link for link in links]
|
||||||
|
return formatted_urls
|
||||||
|
|
||||||
|
|
||||||
|
def scrape_flickr(keywords) -> List[str]:
|
||||||
"""
|
"""
|
||||||
Creates a list of image links from a Flickr search
|
Creates a list of image links from a Flickr search
|
||||||
"""
|
"""
|
||||||
|
@ -46,5 +55,5 @@ def scrap_flickr(keywords) -> List[str]:
|
||||||
images = soup.find_all(
|
images = soup.find_all(
|
||||||
"div", class_="view photo-list-photo-view requiredToShowOnServer awake",
|
"div", class_="view photo-list-photo-view requiredToShowOnServer awake",
|
||||||
)
|
)
|
||||||
image_links = findall("(live.staticflickr.com/\S+.jpg)", str(images))
|
links = extract_urls(images)
|
||||||
return image_links
|
return links
|
||||||
|
|
|
@ -3,6 +3,7 @@ from flask import render_template
|
||||||
from app import app
|
from app import app
|
||||||
from app.forms import DatasetForm
|
from app.forms import DatasetForm
|
||||||
from app.processing import process_data
|
from app.processing import process_data
|
||||||
|
from app.data_request import scrape_flickr
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
|
@ -28,3 +29,9 @@ def visualization():
|
||||||
@app.route("/map")
|
@app.route("/map")
|
||||||
def map():
|
def map():
|
||||||
return render_template("map.html", title="Map")
|
return render_template("map.html", title="Map")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/photos")
|
||||||
|
def photos():
|
||||||
|
images = scrape_flickr("paris")
|
||||||
|
return render_template("photos.html", title="Photos", images=images)
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<a class="nav-link" href="{{ url_for('index') }}">Home <span class="sr-only">(current)</span></a>
|
<a class="nav-link" href="{{ url_for('index') }}">Home <span class="sr-only">(current)</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-link"><a href="{{ url_for('data') }}">Data</a></li>
|
<li class="nav-link"><a href="{{ url_for('data') }}">Data</a></li>
|
||||||
|
<li class="nav-link"><a href="{{ url_for('photos') }}">Photos</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% import 'bootstrap/wtf.html' as wtf %}
|
||||||
|
|
||||||
|
{% block app_content %}
|
||||||
|
<h1>Photos</h1>
|
||||||
|
{% for img_path in images %}
|
||||||
|
<img src="{{img_path|safe}}" alt="Image placeholder" id="photo" style="width: 200px"/>
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue