Skip to main content

dhttp

dhttp, which is pretty short for decorable HTTP, is a simple, yet dynamic, HTTP server written for Python 3.
It is inspired by Node.js's Express library.

"Decorable" is a reference to how extensively decorators are used throughout this project. They are very useful, and are one of the nicest syntaxes for a callback system like this.

Example code

import dhttp
import random

app = dhttp.DHTTPServer(int(sys.argv[1]) if len(sys.argv) > 1 else 8005)

app.alias('/index', '/')
app.alias('/index.htm', '/')
app.alias('/index.html', '/')

test_index = """<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>My first DHTTP server</title>
    </head>

    <body>
        <p><h2>Congratulations!</h2></p>
        <hr>
        <p><b>dhttp {version}</b> is now running on your machine.</p>
        <p>How about <i>{party}</i> to comemorate? :)</p>
    </body>
</html>"""

party_stuff = [
    'a bottle of wine', 'a bottle of champagne', 'a big party',
    'THE party, just', 'THE party', 'lots of cats', 'partyception',
    'balloons and cakes', 'a big-endian cake', 'lots of confetti',
    'the Confetti-o-Tron 2000', 'HTTP juice', 'Spicy Bytes',
    'antimatter', 'cats writing code', 'a smile breaking the 4th wall'
]

@app.get('/')
def serve_index(req, res):
    res.end(test_index.format(
        party = random.choice(party_stuff),
        version = DHTTP_VERSION
    ))

@app.on_log
def print_log(log):
    if log.request.get_header('X-Forwarded-For') is not None:
        log.ip = log.request.get_header('X-Forwarded-For')
        print(log, '  (forwarded)')

    else:
        print(log)

@app.serve_forever
def on_serve():
    print(f"   == Listening on port: {app.port} ==")

Metadata

Release files for dhttp 1.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dhttp 1.3.3
File Size Uploaded Provenance
dhttp-1.3.3.tar.gz 27.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dhttp 1.3.3
File Interpreter ABI Platform
dhttp-1.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 58.5 kB

Release files / dhttp-1.3.3.tar.gz

Download URL dhttp-1.3.3.tar.gz
Size 27.8 kB
Tags Source
SHA-256 checksum
How to use checksums
49fbbc5329602a83df252657ff6c7c11fa29df0df76b816273102dcab7a15eaa
BLAKE2b-256 checksum
How to use checksums
f484102227e6ff6711c6272ff4d10dc1b4576f09628cb4c1dc86dea37ac59437
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.12.4 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.5.3

Release files / dhttp-1.3.3-py3-none-any.whl

Download URL dhttp-1.3.3-py3-none-any.whl
Size 30.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0deb9fbc232449500da6832898aba20c40a4bfc01b84e8be6faee45a1f6307fa
BLAKE2b-256 checksum
How to use checksums
8728ba3aad8d9261622415b988c43dc8d85e5678dcb33550d84991947ac55aa2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.12.4 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.5.3

Security for dhttp 1.3.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.3.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page