More steps, include link to search flickr
This commit is contained in:
parent
7934bacf20
commit
c77ae56ba0
15
main.py
15
main.py
|
@ -12,9 +12,20 @@ enwiki = "en.wikipedia.org/wiki/"
|
|||
|
||||
|
||||
@app.route("/")
|
||||
def start_form() -> str:
|
||||
def start() -> str:
|
||||
"""Start form."""
|
||||
return flask.render_template("start_form.html")
|
||||
return flask.render_template("wikipedia_url.html")
|
||||
|
||||
|
||||
@app.route("/flickr")
|
||||
def flickr_search() -> str:
|
||||
"""Search flickr."""
|
||||
wikipedia_url = flask.request.args["wikipedia"]
|
||||
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
|
||||
)
|
||||
|
||||
|
||||
@app.route("/message")
|
||||
|
|
23
templates/flickr_search.html
Normal file
23
templates/flickr_search.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Flickr mail{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<h1>Flickr mail</h1>
|
||||
<p>Wikipedia article: {{ name }}</p>
|
||||
<p><a href="https://flickr.com/search/?view_all=1&safe_search=3&text={{ '"' + name + '"' | urlencode }}">Search flickr</a></p>
|
||||
|
||||
<form action="{{ url_for("show_message") }}">
|
||||
<input type="hidden" name="wikipedia" value="{{ wikipedia_url }}"></input>
|
||||
<div class="mb-3">
|
||||
<label for="flickr" class="form-label">Flickr URL:</label>
|
||||
<input type="text" class="form-control" id="flickr" name="flickr" required>
|
||||
</div>
|
||||
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
20
templates/wikipedia_url.html
Normal file
20
templates/wikipedia_url.html
Normal file
|
@ -0,0 +1,20 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Flickr mail{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h1>Enter URLs</h1>
|
||||
<form action="{{ url_for("flickr_search") }}">
|
||||
<div class="mb-3">
|
||||
<label for="wikipedia" class="form-label">Wikipedia URL:</label>
|
||||
<input type="text" class="form-control" id="wikipedia" name="wikipedia" required>
|
||||
</div>
|
||||
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in a new issue