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 %}
-

Flickr mail

+
+

Enter URLs

+
+
+ + +
+ + +
+ + {% if name %} +

Wikipedia article: {{ name }}

Search flickr

@@ -18,6 +30,8 @@ + {% endif %}
+
{% endblock %} diff --git a/templates/start_form.html b/templates/start_form.html deleted file mode 100644 index 67e0862..0000000 --- a/templates/start_form.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - Flickr Mail - - - -
-
-

Enter URLs

-
-
- - -
- -
- - -
- - -
- -
-
- - - diff --git a/templates/wikipedia_url.html b/templates/wikipedia_url.html deleted file mode 100644 index e31a938..0000000 --- a/templates/wikipedia_url.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Flickr mail{% endblock %} - -{% block content %} -
-
-

Enter URLs

-
-
- - -
- - -
- -
-
-{% endblock %}