Skip to main content

Webserver (with some utilities) made in sockets!

Project description

Lamp

An asynchronous webserver made with sockets! (Not Finished)

Examples of using Lamp:

from WebLamp import Lamp, Connection

server = Lamp()

@server.route(route = '/', method = ['GET'])
async def home(conn: Connection) -> bytes:

    conn.set_status(200)
    conn.set_body(b'Hello World!')

    return conn.response

server.run(("127.0.0.1", 5000))

1 unique thing about this webserver is you can use a regex in your path/routes as show below

from WebLamp import Lamp, Connection

server = Lamp()

@server.route(route = r'^/u/(?P<userid>[0-9]*)$', method = ['GET'])
async def home(conn: Connection) -> bytes:

    userid = conn.args['userid'] # this came from the regex that was provided

    conn.set_status(200)
    conn.set_body(f'{userid}'.encode())

    return conn.response

server.run(("127.0.0.1", 5000))

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

WebLamp-0.1.0.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

WebLamp-0.1.0-py3-none-any.whl (7.0 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