Skip to main content

A simple python web server frame

Project description

A simple python web server frame

wranning: same flask, not flask!

demo

-> main.py

web server 自定义协议

from bframe.ctx import request
from bframe.frame import Frame


app = Frame(__name__)


@app.get("/favicon.ico")
def index():
    with open("favicon.ico", "rb") as f:
        data = f.read()
    return data


@app.get("/main")
@app.get("/home")
def home():
    return request.Headers


if __name__ == "__main__":
    app.run(address="0.0.0.0")

wsgi支持

若您需要使用wsgi功能的支持,使用WSGIProxy类进行包装即可

from bframe.ctx import request
from bframe.frame import Frame


app = Frame(__name__)


@app.get("/favicon.ico")
def index():
    with open("favicon.ico", "rb") as f:
        data = f.read()
    return data


@app.get("/main")
@app.get("/home")
def home():
    return request.Headers


if __name__ == "__main__":
    from bframe.wsgi_server import WSGIProxy
    from wsgiref.bframe import make_server

    with make_server('', 7256, WSGIProxy(app)) as httpd:
        print("Serving on port 7256...")
        httpd.serve_forever()

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

bframe-0.0.1-py3-none-any.whl (8.9 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