HTTPS and HTTP server framework
Project description
Slinn is a HTTPS and HTTP server framework
Create project
Unix-like (Linux, MacOS, FreeBSD...):
python3 -m slinn create helloworld
cd helloworld
venv/bin/python manage.py create localhost host=localhost host=127.0.0.1
venv/bin/python manage.py run
Windows:
py -m slinn create helloworld
cd helloworld
venv/Scripts/activate
py manage.py create localhost host=localhost host=127.0.0.1
py manage.py run
Simple example
from slinn import Server, Dispatcher, Filter, HttpResponse, Address
dp = Dispatcher()
@dp.route(Filter('/api.*'))
def api(request):
return HttpResponse('{"status": "ok"}')
@dp.route(Filter('.*'))
def helloworld(request):
return HttpResponse('Hello world!')
app = Server(dp, ssl_cert='fullchain.pem', ssl_key='key.pem')
app.listen(Address(8080))
Functions:
Server(self, *dispatchers, ssl_cert: str=None, ssl_key: str=None, http_ver: str='2.0')
Server.listen(self, address: Address)
Address(self, port: int, host: str=None)
Dispatcher(self, hosts: list=None)
Dispatcher.route(self, filter: Filter)
Filter(self, filter: str, methods: list[str]=None)
Filter.check(self, text: str, method: str) -> bool
HttpResponse(self, payload, data: list[tuple]=None, status: str='200 OK', content_type: str='text/plain')
HttpResponse.set_cookie(self, key: str, value)
HttpResponse.make(self, type: str='HTTP/2.0') -> str
HttpRedirect inherits from HttpResponse
HttpRedirect(self, location: str)
Request(self, http_data: str, client_address: tuple[str, int])
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
slinn-1.1.2.tar.gz
(7.9 kB
view details)
File details
Details for the file slinn-1.1.2.tar.gz.
File metadata
- Download URL: slinn-1.1.2.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaf134e61068a483fdeb634fa05c51fee181da7b7a714fb96d8e956d9f7502da
|
|
| MD5 |
00a63dc0f6255cade0e998bdfe12bb52
|
|
| BLAKE2b-256 |
f63af3f43d567d4a6b739e6e17e29eea3a8988ddc70ae4c41d7a85e7202651c0
|