Skip to main content

Simple file-based wiki for Flask

Project description

Flask-Wiki

A lightweight, file-based wiki system built as a Flask extension. Create, edit, search, and manage wiki pages stored as Markdown files on the filesystem -- no database required.

Features

  • Markdown pages with metadata (title, tags)
  • Full-text search powered by Whoosh
  • File/image uploads
  • WikiLinks ([[Page Name]] syntax)
  • Multilingual support
  • Rich editor with live preview (EasyMDE)
  • Customizable templates and permissions

Installation

pip install flask-wiki

Quick start

from flask import Flask
from flask_wiki import Wiki

app = Flask(__name__)
app.config['SECRET_KEY'] = 'your-secret-key'
Wiki(app)

Or using the application factory pattern:

from flask import Flask
from flask_wiki import Wiki

wiki = Wiki()

def create_app():
    app = Flask(__name__)
    app.config['SECRET_KEY'] = 'your-secret-key'
    wiki.init_app(app)
    return app

The wiki will be available at /help by default (configurable via WIKI_URL_PREFIX).

Initialize the search index

Before using search, initialize the Whoosh index:

flask flask_wiki init-index
flask flask_wiki index

How it works

Wiki pages are plain Markdown files stored in a content directory (./data by default). The URL structure mirrors the filesystem: /help/guides/setup maps to data/guides/setup.md.

Each page file has an optional metadata header followed by the Markdown body:

title: My Page Title
tags: setup, guide

# Content starts here

Regular markdown content...

The wiki registers a Flask Blueprint with routes for viewing, editing, searching, and managing pages. Uploaded files (images) are stored in a subfolder and served via middleware.

Permissions

Flask-Wiki uses a callable-based permission system. The host application provides functions that return True or False to control access. By default, everything is open (all lambdas return True).

There are four permission settings:

Setting Purpose
WIKI_READ_VIEW_PERMISSION Controls access to read routes (view pages, search). Returns 403 if False.
WIKI_EDIT_VIEW_PERMISSION Controls access to edit routes (edit, delete, upload). Returns 403 if False.
WIKI_READ_UI_PERMISSION Controls visibility of read-related UI elements in templates.
WIKI_EDIT_UI_PERMISSION Controls visibility of edit buttons/links in templates.

Each permission is a callable (no arguments) that is evaluated per-request. This lets you integrate with any authentication system -- Flask-Login, session-based auth, API tokens, etc.

Example: integrating with Flask-Login

from flask_login import current_user

app.config['WIKI_READ_VIEW_PERMISSION'] = lambda: current_user.is_authenticated
app.config['WIKI_EDIT_VIEW_PERMISSION'] = lambda: current_user.is_authenticated and current_user.has_role('editor')
app.config['WIKI_EDIT_UI_PERMISSION'] = app.config['WIKI_EDIT_VIEW_PERMISSION']

The VIEW permissions are enforced server-side via route decorators. The UI permissions only toggle visibility of buttons and links in the templates -- they do not enforce access control on their own. Typically you'll set the UI permissions to match the view permissions, but you can separate them if needed (e.g., show a "log in to edit" button to anonymous users).

Configuration

Content & storage

Key Default Description
WIKI_HOME 'home' Default page for /
WIKI_URL_PREFIX '/help' URL prefix for the wiki blueprint
WIKI_CONTENT_DIR './data' Directory for Markdown files
WIKI_UPLOAD_FOLDER './data/files' Directory for uploaded images
WIKI_ALLOWED_EXTENSIONS {'png','jpg','jpeg','gif','svg'} Allowed upload types
WIKI_INDEX_DIR './index' Whoosh search index directory

Templates

All templates can be overridden by setting these config values to your own template paths:

Key Default
WIKI_BASE_TEMPLATE 'wiki/base.html'
WIKI_PAGE_TEMPLATE 'wiki/page.html'
WIKI_EDITOR_TEMPLATE 'wiki/editor.html'
WIKI_SEARCH_TEMPLATE 'wiki/search.html'
WIKI_FILES_TEMPLATE 'wiki/files.html'
WIKI_NOT_FOUND_TEMPLATE 'wiki/404.html'
WIKI_FORBIDDEN_TEMPLATE 'wiki/403.html'

Internationalization

Key Default Description
WIKI_CURRENT_LANGUAGE lambda: 'en' Callable returning the current language code
WIKI_LANGUAGES {'en': 'English', 'fr': 'French', 'de': 'German', 'it': 'Italian'} Available languages

Pages can have per-language variants using filename suffixes: page_fr.md, page_de.md, etc. The wiki automatically loads the correct variant based on WIKI_CURRENT_LANGUAGE.

Markdown

Key Default Description
WIKI_MARKDOWN_EXTENSIONS {'codehilite', 'fenced_code'} Additional Python-Markdown extensions

The extensions toc, meta, tables, and a built-in Bootstrap extension are always loaded.

Development

Requirements

  • Python >=3.10,<3.15
  • uv

Setup

git clone <repo-url>
cd flask-wiki
uv sync --frozen

Run the example app

cd examples
uv run flask flask_wiki init-index
uv run flask flask_wiki index
uv run flask run --debug
# Visit http://localhost:5000/help

Run tests

uv run poe run_tests

License

BSD 3-Clause. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_wiki-2.0.0.tar.gz (693.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_wiki-2.0.0-py3-none-any.whl (720.7 kB view details)

Uploaded Python 3

File details

Details for the file flask_wiki-2.0.0.tar.gz.

File metadata

  • Download URL: flask_wiki-2.0.0.tar.gz
  • Upload date:
  • Size: 693.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for flask_wiki-2.0.0.tar.gz
Algorithm Hash digest
SHA256 abe0443cbfe60f2afe765532440073d6c75ebb02a70a561b89f928430c129654
MD5 63b1d50b44ad341499c0dfa0bf314af0
BLAKE2b-256 fb6efec51c340ec69d8929100a11b2f500c7df063704a040dd614a350235e613

See more details on using hashes here.

File details

Details for the file flask_wiki-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: flask_wiki-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 720.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for flask_wiki-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2622f336a033fd393472c92d38a20303e762e719ee58edca271d9c791fd53879
MD5 7543897fa413b3fe08266ef667cdd336
BLAKE2b-256 9445159e87f3191fbd2a15120e17c2799d6e48d42bd439ee76e60c1eb2e70f9e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page