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
Release history Release notifications | RSS feed
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 details)
Built Distribution
File details
Details for the file WebLamp-0.3.0.tar.gz
.
File metadata
- Download URL: WebLamp-0.3.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc6b07a76d3d97c92abd093329eaf98fcab298d141d1535eb00f13746012f597 |
|
MD5 | 2e370b3884f3d57ae7866e2a79f90a78 |
|
BLAKE2b-256 | 4409a1684e1b9a941f285f1ccab71df8fcbbb82909ffc954e20e65d2aa22dd1d |
File details
Details for the file WebLamp-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: WebLamp-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ee571cecd86d5cf12ede95190ff16aaa11cb9bb3f0e7e4acab581013f163942 |
|
MD5 | 38fee14c1a09e2f94f6f5abc0dff8e86 |
|
BLAKE2b-256 | 35fe49c7e2044f69b06781ebffc39a0c2173a43c53a436dcac82e5c9f0534668 |