- Python Falcon Tutorial
- Python Falcon - Home
- Python Falcon - Introduction
- Python Falcon - Environment Setup
- Python Falcon - WSGI vs ASGI
- Python Falcon - Hello World(WSGI)
- Python Falcon - Waitress
- Python Falcon - ASGI
- Python Falcon - Uvicorn
- Python Falcon - API Testing Tools
- Request & Response
- Python Falcon - Resource Class
- Python Falcon - App Class
- Python Falcon - Routing
- Falcon - Suffixed Responders
- Python Falcon - Inspect Module
- Python Falcon - Jinja2 Template
- Python Falcon - Cookies
- Python Falcon - Status Codes
- Python Falcon - Error Handling
- Python Falcon - Hooks
- Python Falcon - Middleware
- Python Falcon - CORS
- Python Falcon - Websocket
- Python Falcon - Sqlalchemy Models
- Python Falcon - Testing
- Python Falcon - Deployment
- Python Falcon Useful Resources
- Python Falcon - Quick Guide
- Python Falcon - Useful Resources
- Python Falcon - Discussion
Python Falcon - Inspect Module
The inspect module is a handy tool that provides information about registered routes and other components of a Falcon application such as middleware, sinks etc.
The inspection of an application can be done by two ways – CLI tool and programmatically. The falcon-inspect-tool CLI script is executed from the command line giving the name of Python script in which Falcon application object is declared.
For example, to inspect application object in studentapi.py −
falcon-inspect-app studentapi:app Falcon App (WSGI) Routes: ⇒ /students - StudentResource: ├── GET - on_get └── POST - on_post ⇒ /students/{id:int} - StudentResource: ├── DELETE - on_delete_student ├── GET - on_get_student └── PUT - on_put_student
The output shows registered routes and the responder methods in the resource class. To perform the inspection programmatically, use the application object as argument to inspect_app() function in the inspect module.
from falcon import inspect from studentapi import app app_info = inspect.inspect_app(app) print(app_info)
Save the above script as inspectapi.py and run it from the command line.
python inspectapi.py Falcon App (WSGI) Routes: ⇒ /students - StudentResource: ├── GET - on_get └── POST - on_post ⇒ /students/{id:int} - StudentResource: ├── DELETE - on_delete_student ├── GET - on_get_student └── PUT - on_put_student
Advertisements
To Continue Learning Please Login
Login with Google