from flask import Flask, render_template from flask_flatpages import FlatPages DEBUG = True FLATPAGES_AUTO_RELOAD = DEBUG FLATPAGES_EXTENSION = '.md' app = Flask(__name__) app.config.from_object(__name__) pages = FlatPages(app) FLATPAGES_MARKDOWN_EXTENSIONS = ['fenced_code', 'tables'] app.config['FLATPAGES_MARKDOWN_EXTENSIONS'] = FLATPAGES_MARKDOWN_EXTENSIONS @app.route('/') def index(): posts = sorted(pages, key=lambda p: p.meta.get('date'), reverse=True) return render_template('index.html', posts=posts) @app.route('//') def post(path): page = pages.get_or_404(path) return render_template('post.html', page=page) @app.route('/about') def about(): return render_template('about.html') if __name__ == "__main__": app.run(port=5001)