Skip to main content

Check and auto-fix broken Flask route usage in templates

Project description

flask-route-checker

CLI to detect ⚠️ and auto-fix 🔧 broken url_for() calls in your Flask templates.


Features

  • ✅ scans all .html templates for url_for() usage
  • 🚨 flags endpoints that don’t exist
  • 🔧 --fix mode rewrites templates + creates backups
  • 🎨 coloured output, dry-run diff viewer, ignore filters, JSON / MD report
  • 🧹 detects unused routes, optional external link checker
  • 🏗️ supports plain app = Flask(__name__) and factory pattern

Quick start

# install
pip install flask-route-checker

# run from your Flask project root
flask-route-checker                       # just report issues
flask-route-checker --fix --backup-dir .backups

# possible erros 
ModuleNotFoundError: No module named 'routes'
two ways to fix 

1. run flask-route-checker from project root + add . to PYTHONPATH
    just run this from the same directory as app.py:
    set PYTHONPATH=.
    flask-route-checker --app app.py # or you main file that runs your flask app 

    if you are on GIT BASH ot UNIX:
    PYTHONPATH=. flask-route-checker --app app.py

2. Turn your routes/ into a proper python package
Make sure the routes/ folder has an __init__.py:

touch routes/__init__.py to make it easier 

| flag                       | purpose                                            |
| -------------------------- | -------------------------------------------------- |
| `--fix`                    | auto-patch broken routes                           |
| `--dry-run`                | show diff, don’t write                             |
| `--backup-dir DIR`         | where fixed templates are backed up                |
| `--ignore-endpoint TEXT`   | skip endpoints containing TEXT (can pass multiple) |
| `--report {json,markdown}` | dump a machine-readable report                     |
| `--unused`                 | list endpoints defined but never used              |
| `--diff`                   | colour diff view (needs **rich**)                  |
| `--factory NAME`           | custom factory instead of `create_app`             |


<h1 align="center">Contributing</h1>
1. Fork 🚀
2. git clone your fork 
3. pip install -e .[dev]
4. Create a branch feat/my-awesome-thing
5. PRs welcome! (Add test if you can)

# ADIOS AMIGO

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_route_checker-0.1.4.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

flask_route_checker-0.1.4-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file flask_route_checker-0.1.4.tar.gz.

File metadata

  • Download URL: flask_route_checker-0.1.4.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for flask_route_checker-0.1.4.tar.gz
Algorithm Hash digest
SHA256 075fe6921d3ed25416facd9ad188235a31860213f0c397348f242f19a1d18290
MD5 614dbbca42568a7e1ee59344e6577f04
BLAKE2b-256 4c042c901fca542a56190f171b8768e99423ba18c002558063753cd56a8255dd

See more details on using hashes here.

File details

Details for the file flask_route_checker-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_route_checker-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 eb5b73947fc9e9a14f26d3fa8ae71b091ee7d24bfc7d04603da51306ce009eb4
MD5 9f79c96c81a1370fbaba3b7ec402e5ee
BLAKE2b-256 fd3dbc7c3ba9c6d6f565a28a67597fff80382376d0da15284991535460513e81

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