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

# localhost/app.py

from slinn import Dispatcher, AnyFilter, LinkFilter, HttpResponse, HttpAPIResponse


dp = Dispatcher('localhost', '127.0.0.1')


@dp(LinkFilter('api'))
def api(request):
    return HttpAPIResponse('{"status": "ok"}')


@dp(AnyFilter)
def helloworld(request):
     return HttpResponse('Hello world!')

To config project you should edit ./project.json

To config app you should edit ./%app%/config.json

Functions:

from slinn import Server

server = Server(*dispatchers: list[Dispatcher], ssl_cert: str=None, ssl_key: str=None, http_ver: str='2.0')
server.address() -> str
server.reload(*dispatchers: list[Dispatcher])
server.listen(address: Address)
from slinn import Address

address = Address(port: int, host: str=None)
from slinn import Dispatcher

dispatcher = Dispatcher(hosts: list=None)
dispatcher.route(filter: Filter)
from slinn import Filter

_filter = Filter(filter: str, methods: list[str]=None)
_filter.check(text: str, method: str) -> bool
_filter.size(text: str, method: str) -> int  # Special method for Smart Navigation

# LinkFilter inherits from Filter
from slinn import LinkFilter

link_filter = LinkFilter(filter: str, methods: list[str]=None)
link_filter.check(text: str, method: str) -> bool

# AnyFilter as same as Filter('.*')
from slinn import AnyFilter
from slinn import HttpResponse

http_response = HttpResponse(payload, data: list[tuple]=None, status: str='200 OK', content_type: str='text/plain')
http_response.set_cookie(key: str, value)
http_response.make(type: str='HTTP/2.0') -> str

# HttpAPIResponse inherits from HttpResponse
from slinn import HttpAPIResponse

http_api_response = HttpAPIResponse(payload, data: list[tuple]=None, status: str='200 OK', content_type: str='text/plain')
http_api_response.set_cookie(key: str, value)
http_api_response.make(type: str='HTTP/2.0') -> str

# HttpRedirect inherits from HttpResponse
from slinn import HttpRedirect

HttpRedirect(location: str)
from slinn import Request

Request(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-2.0.1.tar.gz (12.6 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for slinn-2.0.1.tar.gz
Algorithm Hash digest
SHA256 f62969e5b75d054e47942203f3a255b3fbb2058f14e693c1be4d587b46161221
MD5 6d6820c1dc1e6e9077fe2b599b0ff8de
BLAKE2b-256 2b5cbc06aadd2e3c845aae035cdc936f6b202d2f6b422d6c943aed7444b6fc09

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