Registry / web-framework / flask-autoindex

flask-autoindex

JSON →
library0.6.6pypypi✓ verified 86d ago

Flask-AutoIndex is a Flask extension that automatically generates index pages for Flask applications, mimicking Apache's mod_autoindex. It provides a default visual style for directory listings but also allows for extensive customization of templates and icons. The current stable version is 0.6.6, released in March 2020. While functional, the project appears to be in maintenance mode, with limited recent activity on its GitHub repository.

pip install Flask-AutoIndex
INSTALL
IMPORT
SIG · FLASK-AUTOINDEX
F
flask-autoindex
web-frameworkpythonv0.6.6
Install
5.6s avg
Import
596ms
Disk
30MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.630s · 32MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 5.6s · import 0.563s · 32MB
30MB installed
● package 30MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AutoIndex
from flask_autoindex import AutoIndex
from flask.ext.autoindex import AutoIndex
The `flask.ext` namespace was deprecated and removed in newer Flask versions (Flask 0.11+). Direct import from the package name is required.

This quickstart initializes a Flask application and configures Flask-AutoIndex to serve files from a 'my_files' directory at the `/files` URL path. It explicitly sets `add_url_rules=False` to allow for manual routing, preventing potential conflicts with other Flask routes. Run the script and navigate to `http://127.0.0.1:5000/files` to see the auto-indexed content.

import os from flask import Flask from flask_autoindex import AutoIndex app = Flask(__name__) # Create a dummy directory and file for demonstration demo_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'my_files') os.makedirs(demo_dir, exist_ok=True) with open(os.path.join(demo_dir, 'example.txt'), 'w') as f: f.write('This is an example file managed by Flask-AutoIndex.') # Initialize AutoIndex to serve 'my_files' directory # We set add_url_rules=False to manually define the route, preventing conflicts. idx = AutoIndex(app, browse_root=demo_dir, add_url_rules=False) @app.route('/') def home(): return "<h1>Welcome!</h1><p>Visit <a href='/files'>/files</a> for the auto-indexed directory.</p>" # Manually define routes for AutoIndex to serve content @app.route('/files') @app.route('/files/<path:path>') def autoindex(path='.'): # Call render_autoindex with the path to display the directory content return idx.render_autoindex(path) if __name__ == '__main__': app.run(debug=True)
Debug
Known issues
breakingVersions of Flask-AutoIndex prior to 0.6.4 supported Python 2. Versions 0.6.4 and newer require Python 3.6 or higher. Attempting to use newer versions on Python 2 will result in syntax errors or import issues.
fix
Ensure your project is running on Python 3.6+ for Flask-AutoIndex 0.6.4 and above. Use an older version if Python 2 compatibility is essential (not recommended).
affects: <0.6.4 (Python 2), >=0.6.4 (Python 3.6+)
gotchaBy default, if `add_url_rules` is not explicitly set to `False` during initialization, Flask-AutoIndex may automatically register routes like `/` or `/some_path` which could conflict with your application's custom routes, leading to `AssertionError: View function mapping is overwriting an existing endpoint function`.
fix
When initializing `AutoIndex`, always set `add_url_rules=False` if you intend to define your own `@app.route` decorators for serving the indexed content. Then, manually add the desired routes as shown in the quickstart example.
affects: All versions
gotchaThe `flask.ext` import pattern (e.g., `from flask.ext.autoindex import AutoIndex`) is an outdated Flask mechanism. In modern Flask (0.11+), extensions are imported directly from their package name.
fix
Update your imports to `from flask_autoindex import AutoIndex`. Using `flask.ext` will result in `ModuleNotFoundError`.
affects: Flask 0.11+ (when used with Flask-AutoIndex)
gotchaThe project shows limited recent development activity, with the last PyPI release in March 2020 and last GitHub commit in 2024 (but main functionality largely unchanged since 2020). While it remains functional, it may not receive updates for new Flask features or critical bug fixes promptly.
fix
Be aware that active development might be slow. Consider auditing the code or having a fallback if high-maintenance or cutting-edge features are required.
affects: 0.6.6 and potentially future versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'flask.ext'
Attempting to import Flask-AutoIndex using the old `flask.ext` namespace, which was removed in modern Flask versions (0.11+).
fix
Change the import statement to `from flask_autoindex import AutoIndex`.
AssertionError: View function mapping is overwriting an existing endpoint function: autoindex
This error occurs when Flask-AutoIndex's automatic URL rule creation conflicts with a manually defined Flask route that uses the same endpoint name (often 'autoindex' by default) or URL path.
fix
When initializing `AutoIndex`, pass `add_url_rules=False` and then define your routes for `AutoIndex` manually using `@app.route` decorators and calling `idx.render_autoindex(path)` in the view function, as shown in the quickstart.
Flask-AutoIndex is serving files from '/' (the root of my application) instead of my custom home page.
By default, if `AutoIndex` is initialized without specifying `add_url_rules=False` and `browse_root` points to a high-level directory (like `os.path.curdir`), it can take over the root URL (`/`).
fix
Initialize `AutoIndex` with `add_url_rules=False` and explicitly define your `AutoIndex` routes for a specific path (e.g., `/files`), allowing your root path (`/`) to be handled by a separate Flask view function.
Upgrade
Version history
0.6.6latest on PyPI · released Mar 30, 2020
Audit
Dependencies
FlaskrequiredCore web framework integration.
Flask-SilkrequiredUsed internally by Flask-AutoIndex to serve icons for the directory listings.
Agent activity
2 hits · last 30 days
node
2
Resources
flask-autoindex — pip install flask-autoindex · libregistry