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-AutoIndexVerified import paths — ran on the pinned version, not inferred.
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.
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).
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.
Update your imports to `from flask_autoindex import AutoIndex`. Using `flask.ext` will result in `ModuleNotFoundError`.
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.
Change the import statement to `from flask_autoindex import AutoIndex`.
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.
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.