From a141936b21c433b3a14ab153bed2798ec010eacd Mon Sep 17 00:00:00 2001 From: Karim Hamidou Date: Sat, 26 Mar 2016 22:09:07 -0700 Subject: [PATCH] (test) adding sitemap support --- app.py | 14 +++++++++++++- templates/sitemap.html | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 templates/sitemap.html diff --git a/app.py b/app.py index 2e5826cf..315023cb 100644 --- a/app.py +++ b/app.py @@ -1,7 +1,8 @@ import os import json import datetime -from flask import Flask, render_template, request, redirect, url_for +from flask import (Flask, render_template, request, redirect, + url_for, make_response) from src.render_rfc import render_html_rfc @@ -52,6 +53,17 @@ def list_rfc(): untitled_rfc=sorted_untitled_list) +@app.route('/sitemap.xml') +def sitemap_view(): + """Render website's sitemap.""" + sitemap = render_template('sitemap.html', rfcs=metadata.values()) + + # We need to set the content-type header correctly. + response = make_response(sitemap) + response.headers['Content-Type'] = 'application/xml' + return response + + @app.after_request def add_header(response): """ diff --git a/templates/sitemap.html b/templates/sitemap.html new file mode 100644 index 00000000..42c707f2 --- /dev/null +++ b/templates/sitemap.html @@ -0,0 +1,18 @@ + + + + http://www.rfcspot.com/ + weekly + 0.8 + + {% for rfc in rfcs %} + {% if 'rfc' in rfc %} + + http://www.rfcspot.com/{{ rfc['rfc'] }} + weekly + 0.8 + + {% endif %} + {% endfor %} + + -- 2.43.0