Skip to main content

An HTTP server framework

Project description

Slinn

Slinn is an HTTP server framework
License GitHub top language
GitHub Release GitHub repo size GitHub Repo stars

Simple example

from slinn import (
    ApiDispatcher, AnyFilter, AsyncRequest, HttpResponse,
    HttpRedirect, HttpJSONResponse
)


dp = ApiDispatcher()


@dp.get('api/<str method>')
async def api(request: AsyncRequest, method: str) -> HttpResponse:
    return HttpJSONResponse(
        status='ok',
        method=method,
        ip=request.ip
    )

@dp.get()
@dp.get('index')
async def index() -> HttpResponse:
    return HttpRedirect('/helloworld')


@dp(AnyFilter)
async def helloworld() -> HttpResponse:
     return HttpResponse('Hello world!')

Begin project

Standart

slinn-admin create-project www
cd www
venv/bin/activate
slinn create-app localhost host=localhost host=127.0.0.1

Insert example into localhost/app.py file, then run start.bat or start.sh script

[!TIP] Instead of use example, create app from template slinn template example

Expected output

Loading config...
Apps: firstrun
Debug mode enabled
Smart navigation enabled

Starting server...
HTTP server is available on http://localhost:8080/

To config project you should edit ./project.json

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

Classic

Unix-like (Linux, MacOS, FreeBSD...):
mkdir helloworld 
cd helloworld
python3 -m venv venv
venv/bin/activate
Windows:
mkdir helloworld 
cd helloworld
python3 -m venv venv
venv\Scripts\activate

Insert example into ./example.py and add following code:

from slinn import AsyncServer
import asyncio
asyncio.run(AsyncServer(dp).listen(Address(8080)))

then write python example.py

Excepted output

helloworld $ venv/bin/python example.py
HTTP server is available on http://localhost:8080/

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

slinn-2.3.7-py3-none-any.whl (127.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: slinn-2.3.7.tar.gz
  • Upload date:
  • Size: 99.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.2 Windows/11

File hashes

Hashes for slinn-2.3.7.tar.gz
Algorithm Hash digest
SHA256 788b1676bf7a5e668a1fe61443e28409a5a52787ef4a3c84a003e562a65c4d63
MD5 650d3fc3cb52f7406044ff0113039187
BLAKE2b-256 a7267d00e254dfffa63a7471b4edc2608104588c04b3c5a5b77d8c3f8ef2467d

See more details on using hashes here.

File details

Details for the file slinn-2.3.7-py3-none-any.whl.

File metadata

  • Download URL: slinn-2.3.7-py3-none-any.whl
  • Upload date:
  • Size: 127.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.12.2 Windows/11

File hashes

Hashes for slinn-2.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 96616f417b2e9bfaf911acec0846bcac2a0282e03c9f511c7a48d880475687c3
MD5 7d4e5ab6aaa34199aef2a110b4c179b9
BLAKE2b-256 4d1a910607230e89baa153bc51f61e4acb92f8b80179990ffb906ca4873bdf5a

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