A screamingly fast Python 2/3 WSGI server written in C.

Related tags

WSGI Serversbjoern
Overview

bjoern: Fast And Ultra-Lightweight HTTP/1.1 WSGI Server

Join the chat at https://gitter.im/jonashaag/bjoern

A screamingly fast, ultra-lightweight WSGI server for CPython 2 and CPython 3, written in C using Marc Lehmann's high performance libev event loop and Ryan Dahl's http-parser.

Why It's Cool

bjoern is the fastest, smallest and most lightweight WSGI server out there, featuring

  • ~ 1000 lines of C code
  • Memory footprint ~ 600KB
  • Python 2 and Python 3 support (thanks @yanghao!)
  • Single-threaded and without coroutines or other crap
  • Can bind to TCP host:port addresses and Unix sockets (thanks @k3d3!)
  • Full persistent connection ("keep-alive") support in both HTTP/1.0 and 1.1, including support for HTTP/1.1 chunked responses

Installation

pip install bjoern. See wiki for details.

Usage

Flask example

from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello_world():
    return "Hello, World!"

if __name__ == "__main__":
    import bjoern

    bjoern.run(app, "127.0.0.1", 8000)

Advanced usage

# Bind to TCP host/port pair:
bjoern.run(wsgi_application, host, port)

# TCP host/port pair, enabling SO_REUSEPORT if available.
bjoern.run(wsgi_application, host, port, reuse_port=True)

# Bind to Unix socket:
bjoern.run(wsgi_application, 'unix:/path/to/socket')

# Bind to abstract Unix socket: (Linux only)
bjoern.run(wsgi_application, 'unix:@socket_name')

# Enable statsd metrics. See instrumentation.md for details.
bjoern.run(wsgi_application, host, port, statsd=...)

Alternatively, the mainloop can be run separately:

bjoern.listen(wsgi_application, host, port)
bjoern.run()

# With metrics. See instrumentation.md for details.
bjoern.listen(wsgi_application, host, port)
bjoern.run(statsd=...)

You can also simply pass a Python socket(-like) object. Note that you are responsible for initializing and cleaning up the socket in that case.

bjoern.server_run(socket_object, wsgi_application)
bjoern.server_run(filedescriptor_as_integer, wsgi_application)

# This needs manual compilation with `WANT_STATSD=yes`
bjoern.server_run(socket_object, wsgi_application, enable_statsd=True)
Owner
Jonas Haag
Freelancer available for hire. Founder looking for new challenges. Previously CTO @cashlink
Jonas Haag
A utility for mocking out the Python Requests library.

Responses A utility library for mocking out the requests Python library. Note Responses requires Python 2.7 or newer, and requests = 2.0 Installing p

Sentry 3.8k Jan 02, 2023
The lightning-fast ASGI server. 🦄

The lightning-fast ASGI server. Documentation: https://www.uvicorn.org Community: https://discuss.encode.io/c/uvicorn Requirements: Python 3.6+ (For P

Encode 6k Jan 03, 2023
Sixpack is a language-agnostic a/b-testing framework

Sixpack Sixpack is a framework to enable A/B testing across multiple programming languages. It does this by exposing a simple API for client libraries

1.7k Dec 24, 2022
Python HTTP Server

Python HTTP Server Preview Languange and Code Editor: How to run? Download the zip first. Open the http.py and wait 1-2 seconds. You will see __pycach

SonLyte 16 Oct 21, 2021
A modern API testing tool for web applications built with Open API and GraphQL specifications.

Schemathesis Schemathesis is a modern API testing tool for web applications built with Open API and GraphQL specifications. It reads the application s

Schemathesis.io 1.6k Jan 04, 2023
A drop-in replacement for Django's runserver.

About A drop in replacement for Django's built-in runserver command. Features include: An extendable interface for handling things such as real-time l

David Cramer 1.3k Dec 15, 2022
Let your Python tests travel through time

FreezeGun: Let your Python tests travel through time FreezeGun is a library that allows your Python tests to travel through time by mocking the dateti

Steve Pulec 3.5k Jan 09, 2023
Faker is a Python package that generates fake data for you.

Faker is a Python package that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in yo

Daniele Faraglia 15.2k Jan 01, 2023
Scalable user load testing tool written in Python

Locust Locust is an easy to use, scriptable and scalable performance testing tool. You define the behaviour of your users in regular Python code, inst

Locust.io 20.4k Jan 08, 2023
livereload server in python (MAINTAINERS NEEDED)

LiveReload Reload webpages on changes, without hitting refresh in your browser. Installation python-livereload is for web developers who know Python,

Hsiaoming Yang 977 Dec 14, 2022
Green is a clean, colorful, fast python test runner.

Green -- A clean, colorful, fast python test runner. Features Clean - Low redundancy in output. Result statistics for each test is vertically aligned.

Nathan Stocks 756 Dec 22, 2022
Meinheld is a high performance asynchronous WSGI Web Server (based on picoev)

What's this This is a high performance python wsgi web server. And Meinheld is a WSGI compliant web server. (PEP333 and PEP3333 supported) You can als

Yutaka Matsubara 1.4k Jan 01, 2023
AWS Lambda & API Gateway support for ASGI

Mangum Mangum is an adapter for using ASGI applications with AWS Lambda & API Gateway. It is intended to provide an easy-to-use, configurable wrapper

Jordan Eremieff 1.2k Jan 06, 2023
A screamingly fast Python 2/3 WSGI server written in C.

bjoern: Fast And Ultra-Lightweight HTTP/1.1 WSGI Server A screamingly fast, ultra-lightweight WSGI server for CPython 2 and CPython 3, written in C us

Jonas Haag 2.9k Dec 21, 2022
ASGI specification and utilities

asgiref ASGI is a standard for Python asynchronous web apps and servers to communicate with each other, and positioned as an asynchronous successor to

Django 1.1k Dec 29, 2022
Hypothesis is a powerful, flexible, and easy to use library for property-based testing.

Hypothesis Hypothesis is a family of testing libraries which let you write tests parametrized by a source of examples. A Hypothesis implementation the

Hypothesis 6.4k Jan 01, 2023
A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.

PyAutoGUI PyAutoGUI is a cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard. pip inst

Al Sweigart 7.6k Jan 01, 2023
PyQaver is a PHP like WebServer for Python.

PyQaver is a PHP like WebServer for Python.

Dev Bash 7 Apr 25, 2022
Radically simplified static file serving for Python web apps

WhiteNoise Radically simplified static file serving for Python web apps With a couple of lines of config WhiteNoise allows your web app to serve its o

Dave Evans 2.1k Jan 08, 2023
The successor to nose, based on unittest2

Welcome to nose2 nose2 is the successor to nose. It's unittest with plugins. nose2 is a new project and does not support all of the features of nose.

738 Jan 09, 2023