Combine first and second pages.
This commit is contained in:
parent
1c6a83083a
commit
0768cc101c
16
main.py
16
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,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,19 @@
|
|||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<h1>Flickr mail</h1>
|
||||
<div class="row">
|
||||
<h1>Enter URLs</h1>
|
||||
<form action="{{ url_for(request.endpoint) }}">
|
||||
<div class="mb-3">
|
||||
<label for="wikipedia" class="form-label">Wikipedia URL:</label>
|
||||
<input type="text" class="form-control" id="wikipedia" name="wikipedia" value="{{ wikipedia_url }}" required>
|
||||
</div>
|
||||
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
|
||||
{% if name %}
|
||||
|
||||
<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>
|
||||
|
||||
|
@ -18,6 +30,8 @@
|
|||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -1,32 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Flickr Mail</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9" crossorigin="anonymous">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h1>Enter URLs</h1>
|
||||
<form action="{{ url_for("show_message") }}">
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,20 +0,0 @@
|
|||
{% 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