Skip to main content

A socket webserver made in python!

Project description

Lamp

An asynchronous webserver made with sockets in python!

Examples of using Lamp:

from Weblamp import Domain, Lamp, Connection

server = Lamp()
domain = Domain(('your.domain.com', '127.0.0.1:5000')) 

@domain.add_route(path = '/', method = ['GET'])
async def home(con: Connection) -> tuple:
  return (200, b'Hello World!')

server.add_domain(domain)
server.run(
  bind = ('127.0.0.1', 5000)
)

1 unique thing about this webserver is you can use a regex in your route and domain!

import re

from Weblamp import Domain, Lamp, Connection

server = Lamp()
domain = Domain(('your.domain.com', '127.0.0.1:5000')) 

@domain.add_route(path = re.compile(r'^/u/(?P<userid>[0-9]*)$'), method = ['GET'])
async def home(con: Connection) -> tuple:
    userid = conn.args['userid'] # this came from the regex that was provided

    return (200, userid.encode())

server.add_domain(domain)
server.run(
  bind = ('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.3.0.tar.gz (5.0 kB view hashes)

Uploaded source

Built Distribution

WebLamp-0.3.0-py3-none-any.whl (6.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page