diff --git a/main.py b/main.py index 36e910a..e47275e 100755 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ #!/usr/bin/python3 +"""Find photos on flickr for Wikipedia articls and contact the photographer.""" import collections import json @@ -18,17 +19,14 @@ enwiki = "en.wikipedia.org/wiki/" @app.route("/") def start() -> str: """Start form.""" - return flask.render_template("wikipedia_url.html") - - -@app.route("/flickr") -def flickr_search() -> str: - """Search flickr.""" - wikipedia_url = flask.request.args["wikipedia"] + wikipedia_url = flask.request.args.get("wikipedia") + if not wikipedia_url: + return flask.render_template("combined.html") start = wikipedia_url.find(enwiki) + len(enwiki) - name = unquote(wikipedia_url[start:]).replace("_", " ") return flask.render_template( - "flickr_search.html", name=name, wikipedia_url=wikipedia_url + "combined.html", + name=unquote(wikipedia_url[start:]).replace("_", " "), + wikipedia_url=wikipedia_url, ) diff --git a/templates/flickr_search.html b/templates/combined.html similarity index 61% rename from templates/flickr_search.html rename to templates/combined.html index 9a6d5be..f0c1306 100644 --- a/templates/flickr_search.html +++ b/templates/combined.html @@ -4,7 +4,19 @@ {% block content %}
Wikipedia article: {{ name }}
@@ -18,6 +30,8 @@ + {% endif %}