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 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
Mimesis is a high-performance fake data generator for Python, which provides data for a variety of purposes in a variety of languages.

Mimesis - Fake Data Generator Description Mimesis is a high-performance fake data generator for Python, which provides data for a variety of purposes

Isaak Uchakaev 3.8k Jan 01, 2023
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
Generic automation framework for acceptance testing and RPA

Robot Framework Introduction Installation Example Usage Documentation Support and contact Contributing License Introduction Robot Framework is a gener

Robot Framework 7.7k Dec 31, 2022
A mocking library for requests

httmock A mocking library for requests for Python 2.7 and 3.4+. Installation pip install httmock Or, if you are a Gentoo user: emerge dev-python/httm

Patryk Zawadzki 452 Dec 28, 2022
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
create custom test databases that are populated with fake data

About Generate fake but valid data filled databases for test purposes using most popular patterns(AFAIK). Current support is sqlite, mysql, postgresql

Emir Ozer 2.2k Jan 06, 2023
Automatically mock your HTTP interactions to simplify and speed up testing

VCR.py 📼 This is a Python version of Ruby's VCR library. Source code https://github.com/kevin1024/vcrpy Documentation https://vcrpy.readthedocs.io/ R

Kevin McCarthy 2.3k 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
An HTTP server to easily download and upload files.

httpsweet An HTTP server to easily download and upload files. It was created with flexibility in mind, allowing be used in many different situations,

Eloy 17 Dec 23, 2022
A test fixtures replacement for Python

factory_boy factory_boy is a fixtures replacement based on thoughtbot's factory_bot. As a fixtures replacement tool, it aims to replace static, hard t

FactoryBoy project 3k Jan 05, 2023
splinter - python test framework for web applications

splinter - python tool for testing web applications splinter is an open source tool for testing web applications using Python. It lets you automate br

Cobra Team 2.6k Dec 27, 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
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 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
Mixer -- Is a fixtures replacement. Supported Django, Flask, SqlAlchemy and custom python objects.

The Mixer is a helper to generate instances of Django or SQLAlchemy models. It's useful for testing and fixture replacement. Fast and convenient test-

Kirill Klenov 871 Dec 25, 2022
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
Official mirror of https://gitlab.com/pgjones/hypercorn https://pgjones.gitlab.io/hypercorn/

Hypercorn Hypercorn is an ASGI web server based on the sans-io hyper, h11, h2, and wsproto libraries and inspired by Gunicorn. Hypercorn supports HTTP

Phil Jones 432 Jan 08, 2023
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
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