Skip to main content

A backend HTTP framework for Python.

Project description

Backpipe

Back-Ends simplified.


pip install backpipe

Why the name?

The name 'Backpipe' is inspired by the english word 'Bagpipe'.
I decided to call it 'Backpipe', because it is a Back-End Framework.
It is just a little pun.

Samples

Hello World!

import backpipe

server = backpipe.BackPipe()

@server.get
def hello_world(r: backpipe.Request):
    return (200, "Hello World")

server.run()

What is my IP address?

import backpipe

server = backpipe.BackPipe()

@server.get
def my_ip_address(r: backpipe.Request):
    return (200, r.address)

server.run()

Complex Example

import backpipe

server = backpipe.BackPipe()

@server.any
def wrong_method(r: backpipe.Request):
    return (405, f"Wrong method: {r.method}, use POST.")

@server.unknown
def unknown_method(r: backpipe.Request):
    return (405, f"Unknown method: {r.method}, use POST.")

@server.post
def login(r: backpipe.Request):
    try:
        if r.headers["key"] == "password1234":
            return (200, "Password correct!")
        else:
            return (304, "Password wrong!")
    except KeyError:
        return (400, "invalid request, 'key' header missing.")

server.run()

License

Backpipe is licensed under the GNU GPL v3.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

backpipe-0.3.1.tar.gz (17.9 kB view hashes)

Uploaded Source

Built Distribution

backpipe-0.3.1-py3-none-any.whl (19.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page