redirect to uniform site links

master
tiyn 8 months ago
parent 910e6bcc0a
commit a4d2290e47

@ -1,4 +1,4 @@
from flask import Flask, abort, make_response, render_template, request from flask import (Flask, abort, make_response, redirect, render_template, request, url_for)
from flask_font_awesome import FontAwesome from flask_font_awesome import FontAwesome
import config import config
@ -28,8 +28,12 @@ def page_not_found(e):
language=LANGUAGE), 404 language=LANGUAGE), 404
@app.route("/")
@app.route("/index.html") @app.route("/index.html")
def index_re():
return redirect(url_for("index"))
@app.route("/")
def index(): def index():
content = con_gen.gen_index_string() content = con_gen.gen_index_string()
return render_template("index.html", return render_template("index.html",
@ -40,8 +44,12 @@ def index():
language=LANGUAGE) language=LANGUAGE)
@app.route("/search", methods=["GET", "POST"])
@app.route("/search.html", methods=["GET", "POST"]) @app.route("/search.html", methods=["GET", "POST"])
def search_re():
return redirect(url_for("search"))
@app.route("/search", methods=["GET", "POST"])
def search(): def search():
form = SearchForm() form = SearchForm()
if request.method == "POST": if request.method == "POST":
@ -63,8 +71,12 @@ def search():
language=LANGUAGE), 200 language=LANGUAGE), 200
@app.route("/imprint")
@app.route("/imprint.html") @app.route("/imprint.html")
def imprint_re():
return redirect(url_for("imprint"))
@app.route("/imprint")
def imprint(): def imprint():
return render_template("imprint.html", return render_template("imprint.html",
title=TITLE, title=TITLE,
@ -74,8 +86,12 @@ def imprint():
language=LANGUAGE) language=LANGUAGE)
@app.route("/archive")
@app.route("/archive.html") @app.route("/archive.html")
def archive_re():
return redirect(url_for("archive"))
@app.route("/archive")
def archive(): def archive():
content = con_gen.gen_arch_string() content = con_gen.gen_arch_string()
return render_template("archive.html", return render_template("archive.html",
@ -101,14 +117,20 @@ def entry(path):
@app.route("/feed.xml") @app.route("/feed.xml")
@app.route("/rss.xml") @app.route("/rss.xml")
@app.route("/rss")
def feed_re():
return redirect(url_for("feed"))
@app.route("/feed")
def feed(): def feed():
content = con_gen.get_rss_string() content = con_gen.get_rss_string()
rss_xml = render_template("rss.xml", feed_xml = render_template("feed.xml",
content_string=content, content_string=content,
title=TITLE, title=TITLE,
description=DESCRIPTION, description=DESCRIPTION,
website=WEBSITE) website=WEBSITE)
response = make_response(rss_xml) response = make_response(feed_xml)
response.headers["Content-Type"] = "application/rss+xml" response.headers["Content-Type"] = "application/rss+xml"
return response return response

@ -5,8 +5,8 @@
<title>{{ title }}</title> <title>{{ title }}</title>
<description>{{ description }}</description> <description>{{ description }}</description>
<language>{{ language }}</language> <language>{{ language }}</language>
<link>{{ website }}/feed.xml</link> <link>{{ url_for('feed') }}</link>
<atom:link href="/feed.xml" rel="self" type="application/rss+xml" /> <atom:link href="{{ url_for('feed') }}" rel="self" type="application/rss+xml" />
{% autoescape off %} {% autoescape off %}
{{ content_string }} {{ content_string }}
Loading…
Cancel
Save