Ajout d'un fichier sitemap.xml

This commit is contained in:
theo@manjaro 2022-09-06 13:49:14 +02:00
parent 5a12cb23f2
commit b781ebe8cf
2 changed files with 27 additions and 0 deletions

9
app.py
View File

@ -19,6 +19,7 @@ from flask import Flask
from flask import render_template
from flask import url_for
from flask import request
from flask.helpers import make_response
# Fichiers locaux :
import date_tools
@ -34,6 +35,7 @@ GLOBAL_CONTEXT["SOURCE"] = "https://forge.chapril.org/Wantoo/UniSquat_Python" #
GLOBAL_CONTEXT["CREDITSLINK"] = "https://forge.chapril.org/Wantoo" # Le lien de l'organisation
GLOBAL_CONTEXT["CREDITSNAME"] = "Wantoo" # Le nom de l'organisation
GLOBAL_CONTEXT["DEBUG"] = False # Fait en sorte que le logiciel soit un peu plus expressif
GLOBAL_CONTEXT["DOMAIN"] = "https://unisquat.alwaysdata.net" # Le domaine sur lequel est host l'instance
# Globales
logs = [] # Stoque les différentes requêtes faite sur la route /free_rooms/, sous la forme {"timestamp":timestamp,"depts":[]}
@ -310,6 +312,13 @@ def date_select() :
return render_template("date-select.html", **context, **GLOBAL_CONTEXT)
@app.route("/sitemap.xml")
def sitemap():
sitemap_xml = render_template("sitemap.xml", **GLOBAL_CONTEXT)
response= make_response(sitemap_xml)
response.headers["Content-Type"] = "application/xml"
return response
@app.errorhandler(404)
def error(e):

18
templates/sitemap.xml Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>{{DOMAIN}}</loc>
<changefreq>monthly</changefreq>
<priority>1</priority>
</url>
<url>
<loc>{{DOMAIN}}/app</loc>
<changefreq>monthly</changefreq>
<priority>1</priority>
</url>
<url>
<loc>{{DOMAIN}}/stats</loc>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
</urlset>