{"id":4360,"library":"flask-flatpages","title":"Flask-FlatPages","description":"Flask-FlatPages provides an easy way to integrate flat static pages, written in formats like Markdown or reStructuredText, into a Flask web application. It is currently at version 0.9.0, primarily focusing on maintenance releases and preparing for future feature additions in an eventual 1.0 release.","status":"active","version":"0.9.0","language":"en","source_language":"en","source_url":"https://github.com/Flask-FlatPages/Flask-FlatPages","tags":["flask","static pages","markdown","cms","blog"],"install":[{"cmd":"pip install Flask-FlatPages","lang":"bash","label":"Install Flask-FlatPages"}],"dependencies":[{"reason":"Core web framework dependency.","package":"Flask","optional":false},{"reason":"Required for Markdown content rendering, common but can be replaced with custom renderers.","package":"Markdown","optional":true},{"reason":"Optional for code highlighting within Markdown pages.","package":"Pygments","optional":true}],"imports":[{"symbol":"FlatPages","correct":"from flask_flatpages import FlatPages"},{"symbol":"Page","correct":"from flask_flatpages import Page"}],"quickstart":{"code":"import os\nfrom flask import Flask, render_template\nfrom flask_flatpages import FlatPages\n\n# Configuration\nDEBUG = True\nFLATPAGES_AUTO_RELOAD = DEBUG\nFLATPAGES_EXTENSION = '.md'\nFLATPAGES_ROOT = 'pages'\nFLATPAGES_ENCODING = 'utf-8'\n\napp = Flask(__name__)\napp.config.from_object(__name__)\nflatpages = FlatPages(app)\n\n# Routes\n@app.route('/')\ndef index():\n    # All pages are available via flatpages iterable\n    return render_template('index.html', pages=flatpages)\n\n@app.route('/<path:path>/')\ndef page(path):\n    # Get a specific page, or 404\n    page = flatpages.get_or_404(path)\n    return render_template('page.html', page=page)\n\nif __name__ == '__main__':\n    # Create dummy content and templates for runnable quickstart\n    if not os.path.exists(FLATPAGES_ROOT):\n        os.makedirs(FLATPAGES_ROOT)\n    with open(os.path.join(FLATPAGES_ROOT, 'about.md'), 'w') as f:\n        f.write('---\\ntitle: About Us\\ndate: 2024-05-15\\n---\\n\\n# Welcome to our About Page\\n\\nThis is an example flat page managed by Flask-FlatPages.')\n    \n    if not os.path.exists('templates'):\n        os.makedirs('templates')\n    with open('templates/index.html', 'w') as f:\n        f.write('<!doctype html>\\n<html>\\n<head><title>FlatPages Index</title></head>\\n<body>\\n    <h1>FlatPages Example</h1>\\n    <ul>\\n        {% for page in pages %}\\n            <li><a href=\"{{ url_for(\"page\", path=page.path) }}\">{{ page.meta.get(\"title\", page.path) }}</a></li>\\n        {% endfor %}\\n    </ul>\\n</body>\\n</html>')\n    with open('templates/page.html', 'w') as f:\n        f.write('<!doctype html>\\n<html>\\n<head><title>{{ page.meta.get(\"title\", \"Page\") }}</title></head>\\n<body>\\n    <h1>{{ page.meta.get(\"title\", \"\") }}</h1>\\n    {{ page.html|safe }}\\n</body>\\n</html>')\n\n    # Run the Flask app\n    app.run(port=5000, debug=DEBUG)","lang":"python","description":"This quickstart initializes a Flask application with Flask-FlatPages, serving flat markdown pages. It demonstrates how to configure the extension, list all available pages, and retrieve a specific page based on its path. It also includes boilerplate to create dummy files, allowing the example to run out-of-the-box."},"warnings":[{"fix":"Migrate to using `flask.current_app` directly where possible, or ensure an application context is always pushed when `FlatPages.app` is accessed.","message":"Directly accessing the `FlatPages.app` attribute is deprecated. In versions 0.9 and up, it now wraps `flask.current_app`, and attempting to access it outside of an active Flask application context will raise a `RuntimeError`.","severity":"deprecated","affected_versions":"0.8.3+"},{"fix":"Ensure your Python development and deployment environments are running Python 3.8 or newer to use current versions of Flask-FlatPages.","message":"Support for older Python versions has been progressively dropped. Python 2.7 support was removed in v0.8.2. Python 3.7 and earlier are no longer supported as of v0.9.0, requiring Python 3.8+.","severity":"breaking","affected_versions":"0.8.2+, 0.9.0+"},{"fix":"No direct code changes are typically required. Test existing pages with v0.8.0+ to confirm metadata extraction remains correct.","message":"Metadata parsing was improved in v0.8.0 to be more consistent with other 'FlatPage' style libraries and less strict for pages without explicit metadata. While generally an enhancement, review your existing flat page metadata to ensure it's parsed as expected, especially if you relied on previous implicit behaviors.","severity":"gotcha","affected_versions":"0.8.0+"},{"fix":"Always update Flask-FlatPages and its dependencies (e.g., Flask, Markdown) to the latest stable versions. Regularly review your project's dependencies for security alerts.","message":"Multiple releases have included updates to underlying dependencies or dropped support for older Python versions to address security vulnerabilities. Running outdated versions can expose your application to known security risks.","severity":"breaking","affected_versions":"All versions prior to 0.9.0"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}