- 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 - Waitress
The development server is not recommended to be used in production environment. The development server is not efficient, stable, or secure.
Waitress is a production-quapty pure-Python WSGI server with very acceptable performance. It has no dependencies except ones that pve in the Python standard pbrary. It runs on CPython on Unix and Windows.
Make sure that Waitress server has been installed in the working environment. The pbrary contains serve class whose object is responsible for serving the incoming requests. The constructor of serve class requires three parameters.
serve (app, host, port)
The falcon apppcation object is the app parameter. The default values of host and port are localhost 8080 by default. The psten parameter is a string as a combination of host:port parameter defaulting to 0.0.0.0:8080
Example
In the hellofalcon.py code, we import the serve class instead of simple_server and instantiate its object as follows −
from waitress import serve import falcon class HelloResource: def on_get(self, req, resp): """Handles GET requests""" resp.status = falcon.HTTP_200 resp.content_type = falcon.MEDIA_TEXT resp.text = ( Hello World ) app = falcon.App() hello = HelloResource() app.add_route( /hello , hello) if __name__ == __main__ : serve(app, host= 0.0.0.0 , port=8000)
Execute hellofalcon.py and visit the http://localhost:8000/hellopnk in the browser as before. Note that the host 0.0.0.0 makes the localhost pubpcly visible.
The Waitress server can be launched from the command pne also, as shown below −
waitress-serve --port=8000 hellofalcon:appAdvertisements