commit e537dcdb4f9686d26396870a0b263d72c4a04519
parent 5225d303302a2d57058c4d10e79aa0a998ee518a
Author: Natalie Pendragon <natpen@natpen.net>
Date: Thu, 5 Mar 2020 08:55:16 -0500
[serve] Add seed request tracking
Diffstat:
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -130,3 +130,5 @@ dmypy.json
# Search index files
/index/
+
+/seed-requests.txt
diff --git a/gus/serve.py b/gus/serve.py
@@ -26,6 +26,8 @@ def _render_header():
def _render_footer():
return [
+ "",
+ "=> /add-seed See any missing results? Add a gemini URL to the index here."
]
@@ -148,6 +150,23 @@ def search(request):
return Response(Status.INPUT, "Search query")
+@app.route("/add-seed")
+def add_seed(request):
+ data = _render_header()
+ if request.query:
+ with open("seed-requests.txt", "a") as seed_file:
+ seed_file.write("{}\n".format(request.query))
+ data.extend([
+ "",
+ "Thank you for the addition! GUS will attempt to crawl the following URL the next time the index is built.",
+ "",
+ request.query
+ ])
+ return Response(Status.SUCCESS, "text/gemini", "\n".join(data))
+ else:
+ return Response(Status.INPUT, "Gemini URL")
+
+
def main():
args = jetforce.command_line_parser().parse_args()
ssl_context = jetforce.make_ssl_context(