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 route and domain!
from WebLamp import Lamp, Connection
import re
server = Lamp()
@server.route(route = re.compile(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
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.1.6.tar.gz
(5.7 kB
view details)
Built Distribution
File details
Details for the file WebLamp-0.1.6.tar.gz
.
File metadata
- Download URL: WebLamp-0.1.6.tar.gz
- Upload date:
- Size: 5.7 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.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
cb100116c7e083b203842310308f2a3f6508f20dfbbc705a08857077366ed360
|
|
MD5 |
25682e3a0c590df3465b6e95bc968a03
|
|
BLAKE2b-256 |
cbcf1fbe65d14087d7dbe2a9995f38627e8ecc3aaedd717310be78293d4d83b7
|
File details
Details for the file WebLamp-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: WebLamp-0.1.6-py3-none-any.whl
- Upload date:
- Size: 7.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.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
2cd2b6deb8985dd96346c7849207cf4e4e241fd2604262bba6de045f110de87d
|
|
MD5 |
35f8a8fe2a0b8f30b25fbeae460f3f4a
|
|
BLAKE2b-256 |
1963b26deeca42e497d5895797d8cd0b42ea4b3685ced71e4af219c5238d816d
|