Skip to main content

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 HttpAPIResponse('{"status": "ok"}')


@dp.route(Filter('.*'))
def helloworld(request):
     return HttpResponse('Hello world!')

# The following code is not required when using manage.py
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
HttpAPIResponse(self, payload, data: list[tuple]=None, status: str='200 OK', content_type: str='text/plain')
HttpAPIResponse.set_cookie(self, key: str, value)
HttpAPIResponse.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


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.2.1.tar.gz (10.3 kB view details)

Uploaded Source

File details

Details for the file slinn-1.2.1.tar.gz.

File metadata

  • Download URL: slinn-1.2.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for slinn-1.2.1.tar.gz
Algorithm Hash digest
SHA256 356261fad8a566c0789ab59fbb4e3bf2fb2a87003837ba1ab63b9d2ea810dc18
MD5 027607ca749cbc15dfcf70e59a01ec8b
BLAKE2b-256 db2eb53b76a9ac135a00a2e1e90c6ee519217586d29b9384b5575bf4c1be5072

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page