{"id":13500200,"url":"https://github.com/romanvm/WsgiBoostServer","last_synced_at":"2025-03-29T05:33:16.816Z","repository":{"id":146101371,"uuid":"56589111","full_name":"romanvm/WsgiBoostServer","owner":"romanvm","description":"Python WSGI/HTTP server written in C++","archived":false,"fork":false,"pushed_at":"2017-04-14T15:17:01.000Z","size":862,"stargazers_count":32,"open_issues_count":0,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-31T18:38:40.616Z","etag":null,"topics":["asio","boost","cpp","http-server","https-server","python","wsgi-server"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/romanvm.png","metadata":{"files":{"readme":"Readme.rst","changelog":"Changelog.rst","contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-04-19T10:54:12.000Z","updated_at":"2023-07-07T08:05:05.000Z","dependencies_parsed_at":"2023-05-14T23:30:29.349Z","dependency_job_id":null,"html_url":"https://github.com/romanvm/WsgiBoostServer","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanvm%2FWsgiBoostServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanvm%2FWsgiBoostServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanvm%2FWsgiBoostServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romanvm%2FWsgiBoostServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/romanvm","download_url":"https://codeload.github.com/romanvm/WsgiBoostServer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246145013,"owners_count":20730494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asio","boost","cpp","http-server","https-server","python","wsgi-server"],"created_at":"2024-07-31T22:00:53.100Z","updated_at":"2025-03-29T05:33:11.800Z","avatar_url":"https://github.com/romanvm.png","language":"C++","readme":"WsgiBoostServer\n###############\n\n.. image:: https://travis-ci.org/romanvm/WsgiBoostServer.svg?branch=master\n    :target: https://travis-ci.org/romanvm/WsgiBoostServer\n.. image:: https://ci.appveyor.com/api/projects/status/5q3hlfplc9xqtm4y/branch/master?svg=true\n    :target: https://ci.appveyor.com/project/romanvm/wsgiboostserver\n\nThe project is closed!\n======================\n\nUnfortunately, I found out that using WsgiBoostServer with various Python\npackages that include compiled binary modules often leads to Python interpreter crashes because of\ninterpreter memory corruption. This happens both on Windows and Linux. Since WsgiBoostServer follows\n(more or less) modern C++ best practices and does not use things like raw pointers and C-style arrays,\nthis probably happens because some libraries (Boost.Asio?) do not work well inside a Python\ninterpreter.\n\nSince my C++ skills are limited, finding the root cause is beyond my abilities. Feel free to inspect the code\n(maybe I've missed something) or use it as a starting point for your own projects.\nWsgiBoostServer does work well with pure-Python WSGI applications and static files, after all.\n\nIn the future I may return to the project if by some happy chance I find out what is wrong with it.\nBut for now I put it on hold. It was fun to code WsgiBoostServer\nand I learned a lot about C++ and Python in the process.\n\nInformation\n===========\n\nWsgiBoostServer is an asynchronous multi-threaded WSGI and HTTP server written\nas a Python extension module in C++ using `Boost.Asio`_ and `Pybind11`_ libraries.\nIt can serve both Python WSGI applications and static files.\nBecause it is written in C++, WsgiBoostServer is faster than pure Python\nsolutions, like `Waitress`_. It can be used for hosting Python micro-services\nand/or static files. WsgiBoostServer also supports HTTPS protocol.\n\nIn **Releases** section of this repository you can find compiled wheels with HTTPS support\n(statically linked against Boost libraries) for Python 3.6 on Windows (32 and 64 bit),\nfor various Python 3 versions on Linux x64, and for Python 3.4 on Raspberry Pi 2 (if I'm not too lazy to compile this).\n\nYou can install those binary wheels into your Python environment with pip::\n\n  $pip install \u003clink to a .whl file\u003e\n\n\nMain Features\n=============\n\n**WSGI Server**:\n\n- Compliant with `PEP-3333`_.\n- Releases GIL for pure C++ operations, allowing more effective multi-threading.\n- Uses ``Transfer-Encoding: chunked`` if a WSGI application does not provide\n  ``Content-Length`` header (like Django by default).\n- Can be used as a regular module in any Python application.\n\n**HTTP Server**:\n\n- Works on pure C++ level, effectively bypassing GIL.\n- Determines MIME for most file types.\n- Uses gzip compression for common textual formats: ``txt``/``html``/``xml``/``css``/``js``/``json``.\n- Supports ``If-Modified-Since`` and ``If-None-Match`` headers.\n- Supports ``Range`` header.\n- Checks if requested files are really located within specified content folders\n  to forbid requesting files by arbitrary paths (for security reasons).\n\nBenchmarks\n==========\n\nPerformance benchmarks of WsgiBoostServer compared to pure-Python\n`Waitress`_ WSGI server and Node.js can be found `here`_.\nAccording to those benchmarks WsgiBoostServer is about 2 times faster than\nWaitress and about 20% faster (with multiple threads) than Node.js.\n\nCompatibility\n=============\n\n- **OS**: Windows, Linux. In theory, WsgiBoostServer can be built and used on any OS that has\n  a C++ 11/14-compatible compiler and supports Python ``setuptools``.\n- **Python 3** (tested with 3.4, 3.5 and 3.6). Python 2 is no longer supported!\n- **Boost**: tested with 1.55 and above.\n- **Compilers**: GCC 4.9+, MS Visual Studio 2015 Update 3 and above.\n\nUsage\n=====\n\nSimple example with `Flask`_ micro-framework:\n\n.. code-block:: python\n\n  #!/usr/bin/env python\n\n  from flask import Flask\n  from wsgi_boost import WsgiBoostHttp\n\n  app = Flask(__name__)\n\n\n  # Simple Flask application\n  @app.route('/')\n  def hello_world():\n      return 'Hello World!'\n\n\n  # Create a server on the port 8080 with 4 threads\n  httpd = WsgiBoostHttp(port=8080, threads=4)\n  # Set the WSGI app to serve\n  httpd.set_app(app)\n  # Serve static files from a directory\n  httpd.add_static_route(r'^/files', '/var/www/files')\n  httpd.start()\n\nMore advanced examples with Flask and Django frameworks can be found ``examples`` folder.\nAlso see docstrings in ``wsgi_boost/wsgi_boost.cpp`` file for detailed information on\nWsgiBoostServer API.\n\nHTTPS Support\n=============\n\nWsgiBoostServer provides ``WsgiBoostHttps`` class that allows to serve your\nWSGI application and static files via a secure connection. To use HTTPS,\nin the preceding example you need to replace ``WsgiBoostHttp`` class\nwith ``WsgiBoostHttps`` like this:\n\n.. code-block:: python\n\n  httpd = WsgiBoostHttps('fullchain.pem', 'privkey.pem', port=443, threads=4)\n  # Redirect all non-secure HTTP requests from port 80 (default) to HTTPS port\n  httpd.redirect_http = True\n\nHere ``'fullchain.pem'`` and ``'privkey.pem'`` are paths to *full* HTTPS certificate\nchain and private key files respectively. If your private key is password-protected\nyou can provide a password via ``HTTPS_KEY_PASS`` environment variable.\n\nIt is recommended to obtain a HTTPS certificate from a trusted Certificate Authority\nbut for testing purposes you can create a `self-signed certificate`_.\nNote that most programs won't accept such certificate with default security\nsettings. For example, in browsers you need to add your site to browser's security\nexceptions. With ``curl`` you need to use ``-k`` option, and with Python ``requests``\nlibrary you need to provide ``verify=False`` argument to request functions.\n\nOptionally, you can generate parameters for `Diffie-Hellman`_ key exchange::\n\n  $openssl dhparam -out dh.pem 2048\n\nIt is strongly recommended to use at least 2048 bit prime number length.\nA path to the generated file can be passed as the third positional parameter\nto ``WsgiBoostHttps`` constructor.\n\nIf you you want to get a free trusted certificate from `Let's Enccrypt`_ for a site\nhosted on WsgiBoostServer, you can use their ``certbot`` utility with ``--webroot`` option.\nIn this case before obtaining a certificate you need to add a static route\nto ``--webroot-path`` folder:\n\n.. code-block:: python\n\n  httpd.add_static_route(r'^/\\.well-known', '/path/to/webroot-dir')\n\n\nCompilation\n===========\n\nSee `compilation instructions \u003cCompilation.rst\u003e`_.\n\n.. _Boost.Asio: http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio.html\n.. _Pybind11: https://github.com/pybind/pybind11\n.. _Waitress: https://github.com/Pylons/waitress\n.. _Flask: http://flask.pocoo.org\n.. _PEP-3333: https://www.python.org/dev/peps/pep-3333\n.. _here: https://github.com/romanvm/WsgiBoostServer/blob/master/benchmarks/benchmarks.rst\n.. _self-signed certificate: http://www.akadia.com/services/ssh_test_certificate.html\n.. _Diffie-Hellman: https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange\n.. _Let's Enccrypt: https://letsencrypt.org\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromanvm%2FWsgiBoostServer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromanvm%2FWsgiBoostServer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromanvm%2FWsgiBoostServer/lists"}