Missing robots.txt causes internal server error #129

This commit is contained in:
Daniel Grams 2021-02-24 15:44:20 +01:00
parent 8b10fa270b
commit 111e5e57bb
3 changed files with 9 additions and 14 deletions

View File

@ -56,8 +56,10 @@ cache_path = (
)
dump_path = os.path.join(cache_path, "dump")
img_path = os.path.join(cache_path, "img")
sitemap_path = os.path.join(cache_path, "sitemap.xml")
robots_txt_path = os.path.join(cache_path, "robots.txt")
sitemap_file = "sitemap.xml"
robots_txt_file = "robots.txt"
sitemap_path = os.path.join(cache_path, sitemap_file)
robots_txt_path = os.path.join(cache_path, robots_txt_file)
# i18n
app.config["BABEL_DEFAULT_LOCALE"] = "de"

View File

@ -233,7 +233,7 @@
{% if link %}
<div>
<i class="fa fa-fw fa-link" data-toggle="tooltip" title="{{ _('Link') }}"></i>
<a href="{{ link }}" target="_blank" rel="noopener noreferrer">{{ link }}</a>
<a href="{{ link }}" target="_blank" rel="noopener noreferrer" style="word-break: break-all;">{{ link }}</a>
</div>
{% endif %}
{% endmacro %}

View File

@ -1,18 +1,11 @@
import json
import os.path
from flask import (
redirect,
render_template,
request,
send_file,
send_from_directory,
url_for,
)
from flask import redirect, render_template, request, send_from_directory, url_for
from flask_babelex import gettext
from markupsafe import Markup
from project import app, dump_path, robots_txt_path, sitemap_path
from project import app, cache_path, dump_path, robots_txt_file, sitemap_file
from project.services.admin import upsert_settings
from project.views.utils import track_analytics
@ -97,9 +90,9 @@ def static_from_root():
@app.route("/robots.txt")
def robots_txt():
return send_file(robots_txt_path)
return send_from_directory(cache_path, robots_txt_file)
@app.route("/sitemap.xml")
def sitemap_xml():
return send_file(sitemap_path)
return send_from_directory(cache_path, sitemap_file)