Hypercorn is an Asynchronous Server Gateway Interface (ASGI) web server for Python, designed to serve ASGI-compatible applications. It acts as the bridge between the internet and your asynchronous Python web application, handling the low-level details of network communication and translating them into a standardized interface that your ASGI application can understand and respond to.
Key features and characteristics of Hypercorn include:
- ASGI Compliance: It fully adheres to the ASGI specification (versions 2 and 3), enabling it to run any ASGI application developed with frameworks like FastAPI, Starlette, Quart, Django Channels, or raw ASGI applications.
- Protocol Support: Hypercorn supports modern web protocols out of the box, including HTTP/1.1, HTTP/2, and WebSockets, allowing for robust and interactive web applications.
- Asynchronous I/O: Built upon Python's standard `asyncio` library, Hypercorn is inherently asynchronous, allowing it to handle numerous concurrent connections efficiently without blocking, making it suitable for high-concurrency environments.
- Production Ready: It offers a rich set of configuration options suitable for production deployments, such as worker management, binding to specific IP addresses and ports, TLS/SSL support for secure connections, access logging, and various performance tunings.
- Flexibility in Deployment: Hypercorn can be run directly as a standalone ASGI server. Additionally, for more complex deployment scenarios or integration with existing infrastructure, it can be used as a worker class with traditional WSGI servers like Gunicorn.
- Performance: Engineered for high performance, Hypercorn leverages its asynchronous architecture to serve web requests quickly and reliably.
In summary, if you are developing an asynchronous Python web application, Hypercorn provides a robust, compliant, and performant server environment to bring your application to users.
Example Code
First, install hypercorn and a minimal ASGI framework like Starlette:
pip install hypercorn starlette
Create a file named 'app.py'
from starlette.applications import Starlette
from starlette.responses import PlainTextResponse
from starlette.routing import Route
Define asynchronous endpoint functions
async def homepage(request):
return PlainTextResponse('Hello from Hypercorn!')
async def greet_name(request):
name = request.path_params.get('name', 'World')
return PlainTextResponse(f'Hello, {name}!')
Define routes for the application
routes = [
Route('/', endpoint=homepage),
Route('/greet/{name}', endpoint=greet_name),
]
Initialize the Starlette application
app = Starlette(routes=routes)
To run this application:
1. Save the code above as 'app.py'.
2. Open your terminal or command prompt in the same directory as 'app.py'.
3. Execute the command: hypercorn app:app
Once the server starts, open your web browser and navigate to:
- http://127.0.0.1:8000/ (Should display 'Hello from Hypercorn!')
- http://127.0.0.1:8000/greet/Alice (Should display 'Hello, Alice!')
- http://127.0.0.1:8000/greet/Bob (Should display 'Hello, Bob!')








Hypercorn