uvicorn

An ASGI web server, for Python. ๐Ÿฆ„

https://github.com/Kludex/uvicorn

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • โœ“
    CITATION.cff file
    Found CITATION.cff file
  • โœ“
    codemeta.json file
    Found codemeta.json file
  • โœ“
    .zenodo.json file
    Found .zenodo.json file
  • โ—‹
    DOI references
  • โ—‹
    Academic publication links
  • โ—‹
    Academic email domains
  • โ—‹
    Institutional organization owner
  • โ—‹
    JOSS paper metadata
  • โ—‹
    Scientific vocabulary similarity
    Low similarity (16.0%) to scientific vocabulary

Keywords

asgi asyncio http http-server python
Last synced: 4 months ago · JSON representation ·

Repository

An ASGI web server, for Python. ๐Ÿฆ„

Basic Info
  • Host: GitHub
  • Owner: Kludex
  • License: bsd-3-clause
  • Language: Python
  • Default Branch: master
  • Homepage: https://www.uvicorn.org/
  • Size: 3.43 MB
Statistics
  • Stars: 9,668
  • Watchers: 95
  • Forks: 839
  • Open Issues: 67
  • Releases: 64
Topics
asgi asyncio http http-server python
Created over 8 years ago · Last pushed 4 months ago
Metadata Files
Readme Changelog Contributing Funding License Citation

README.md

uvicorn

An ASGI web server, for Python.


Build Status Package version Supported Python Version

Documentation: https://www.uvicorn.org


Uvicorn is an ASGI web server implementation for Python.

Until recently Python has lacked a minimal low-level server/application interface for async frameworks. The ASGI specification fills this gap, and means we're now able to start building a common set of tooling usable across all async frameworks.

Uvicorn supports HTTP/1.1 and WebSockets.

Quickstart

Install using pip:

shell $ pip install uvicorn

This will install uvicorn with minimal (pure Python) dependencies.

shell $ pip install 'uvicorn[standard]'

This will install uvicorn with "Cython-based" dependencies (where possible) and other "optional extras".

In this context, "Cython-based" means the following:

  • the event loop uvloop will be installed and used if possible.
  • the http protocol will be handled by httptools if possible.

Moreover, "optional extras" means that:

  • the websocket protocol will be handled by websockets (should you want to use wsproto you'd need to install it manually) if possible.
  • the --reload flag in development mode will use watchfiles.
  • windows users will have colorama installed for the colored logs.
  • python-dotenv will be installed should you want to use the --env-file option.
  • PyYAML will be installed to allow you to provide a .yaml file to --log-config, if desired.

Create an application, in example.py:

```python async def app(scope, receive, send): assert scope['type'] == 'http'

await send({
    'type': 'http.response.start',
    'status': 200,
    'headers': [
        (b'content-type', b'text/plain'),
    ],
})
await send({
    'type': 'http.response.body',
    'body': b'Hello, world!',
})

```

Run the server:

shell $ uvicorn example:app


Why ASGI?

Most well established Python Web frameworks started out as WSGI-based frameworks.

WSGI applications are a single, synchronous callable that takes a request and returns a response. This doesnโ€™t allow for long-lived connections, like you get with long-poll HTTP or WebSocket connections, which WSGI doesn't support well.

Having an async concurrency model also allows for options such as lightweight background tasks, and can be less of a limiting factor for endpoints that have long periods being blocked on network I/O such as dealing with slow HTTP requests.


Alternative ASGI servers

A strength of the ASGI protocol is that it decouples the server implementation from the application framework. This allows for an ecosystem of interoperating webservers and application frameworks.

Daphne

The first ASGI server implementation, originally developed to power Django Channels, is the Daphne webserver.

It is run widely in production, and supports HTTP/1.1, HTTP/2, and WebSockets.

Any of the example applications given here can equally well be run using daphne instead.

$ pip install daphne $ daphne app:App

Hypercorn

Hypercorn was initially part of the Quart web framework, before being separated out into a standalone ASGI server.

Hypercorn supports HTTP/1.1, HTTP/2, and WebSockets.

It also supports the excellent trio async framework, as an alternative to asyncio.

$ pip install hypercorn $ hypercorn app:App

Mangum

Mangum is an adapter for using ASGI applications with AWS Lambda & API Gateway.

Granian

Granian is an ASGI compatible Rust HTTP server which supports HTTP/2, TLS and WebSockets.


Uvicorn is BSD licensed code.
Designed & crafted with care.

— ๐Ÿฆ„ —

Owner

  • Name: Marcelo Trylesinski
  • Login: Kludex
  • Kind: user
  • Location: Utrecht, Netherlands
  • Company: @encode @pydantic

Software Engineer @ Pydantic ๐Ÿ‡ง๐Ÿ‡ท๐Ÿ‡บ๐Ÿ‡พ๐Ÿ‡ฎ๐Ÿ‡น Uvicorn & Starlette maintainer ๐Ÿฆ„๐ŸŒŸ FastAPI Expert โšก

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: Uvicorn
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Marcelo
    family-names: Trylesinski
    email: marcelotryle@gmail.com
  - given-names: Tom
    family-names: Christie
    email: tom@tomchristie.com
repository-code: 'https://github.com/encode/uvicorn'
url: 'https://www.uvicorn.org/'
abstract: Uvicorn is an ASGI web server implementation for Python.
keywords:
  - asgi
  - server
license: BSD-3-Clause

GitHub Events

Total
  • Watch event: 9
  • Issue comment event: 5
  • Pull request event: 3
Last Year
  • Watch event: 9
  • Issue comment event: 5
  • Pull request event: 3

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 2
  • Total pull requests: 12
  • Average time to close issues: N/A
  • Average time to close pull requests: 6 days
  • Total issue authors: 2
  • Total pull request authors: 9
  • Average comments per issue: 0.5
  • Average comments per pull request: 0.25
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 3
Past Year
  • Issues: 2
  • Pull requests: 12
  • Average time to close issues: N/A
  • Average time to close pull requests: 6 days
  • Issue authors: 2
  • Pull request authors: 9
  • Average comments per issue: 0.5
  • Average comments per pull request: 0.25
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 3
Top Authors
Issue Authors
  • tri-dataxight (1)
  • mattp- (1)
Pull Request Authors
  • dependabot[bot] (3)
  • secrett2633 (2)
  • Ngone6325 (1)
  • activecat (1)
  • lddfym (1)
  • vvanglro (1)
  • LincolnPuzey (1)
  • ollanta (1)
  • rnv812 (1)
Top Labels
Issue Labels
Pull Request Labels
dependencies (3) python (3)

Dependencies

.github/workflows/publish.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v4 composite
.github/workflows/test-suite.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v4 composite
pyproject.toml pypi
  • click >=7.0
  • h11 >=0.8
  • typing_extensions >=4.0; python_version < '3.11'
requirements.txt pypi
  • a2wsgi ==1.8.0
  • build ==1.0.3
  • coverage ==7.3.1
  • coverage-conditional-plugin ==0.9.0
  • cryptography ==41.0.6
  • httpx ==0.25.2
  • mkdocs ==1.5.2
  • mkdocs-material ==9.1.21
  • mypy ==1.7.1
  • pytest ==7.4.3
  • pytest-mock ==3.11.1
  • ruff ==0.1.6
  • trustme ==1.1.0
  • twine ==4.0.2
  • types-click ==7.1.8
  • types-pyyaml ==6.0.12.12
  • watchgod ==0.8.2
  • websockets ==12.0
  • wsproto ==1.2.0