Python Falcon Tutorial
Selected Reading
- Python Falcon - Discussion
- Python Falcon - Useful Resources
- Python Falcon - Quick Guide
- Python Falcon - Deployment
- Python Falcon - Testing
- Python Falcon - Sqlalchemy Models
- Python Falcon - Websocket
- Python Falcon - CORS
- Python Falcon - Middleware
- Python Falcon - Hooks
- Python Falcon - Error Handling
- Python Falcon - Status Codes
- Python Falcon - Cookies
- Python Falcon - Jinja2 Template
- Python Falcon - Inspect Module
- Falcon - Suffixed Responders
- Python Falcon - Routing
- Python Falcon - App Class
- Python Falcon - Resource Class
- Request & Response
- Python Falcon - API Testing Tools
- Python Falcon - Uvicorn
- Python Falcon - ASGI
- Python Falcon - Waitress
- Python Falcon - Hello World(WSGI)
- Python Falcon - WSGI vs ASGI
- Python Falcon - Environment Setup
- Python Falcon - Introduction
- Python Falcon - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Python Falcon - Inspect Module
Python Falcon - Inspect Module
The inspect module is a handy tool that provides information about registered routes and other components of a Falcon apppcation such as middleware, sinks etc.
The inspection of an apppcation can be done by two ways – CLI tool and programmatically. The falcon-inspect-tool CLI script is executed from the command pne giving the name of Python script in which Falcon apppcation object is declared.
For example, to inspect apppcation 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 apppcation 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 pne.
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_studentAdvertisements