Skip to main content

A lightweight webserver implementation [inspired by flask]

Project description

ksalf

PyPI

A lightweight experimental HTTP handler inspired by flask.
! This is just a experimental (fun) project, please don't use it in production !

Implemtation

Ksalf is a lightweight handler for the python (base) http server .
It provides new feature like URL parsing and HTML responses, to the python in-build http server.
Ksalf currently only supports GET requests.
The project was inspired by the flask python project.

Installtion

pip install ksalf

Example

from http.server import HTTPServer
from ksalf import HTTPHandler

class Handler(HTTPHandler):

    @HTTPHandler.route("/health")
    def GET(self):
        self.respond(b'healthy')

if __name__ == "__main__":
    PORT = 8080
    httpd = HTTPServer(('0.0.0.0', PORT), Handler)
    print("Server running on http://localhost:" + str(PORT))
    httpd.serve_forever()

This example would serve a simple web app on your localhost:8080.
You can register a route with @HTTPHandler.route("/<your_route>").
GET requests always get processed by the def GET(self): implementation.
curl

curl localhost:8080/health

Response

healthy

Future Development

  • Implement tests
  • Support other request methods than just GET
  • Advanced URL parsing
  • Enhance HTML Responses

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

ksalf-0.0.2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

ksalf-0.0.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file ksalf-0.0.2.tar.gz.

File metadata

  • Download URL: ksalf-0.0.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.3

File hashes

Hashes for ksalf-0.0.2.tar.gz
Algorithm Hash digest
SHA256 041174e6ec8a165ed8455b29be49962f3cc0b346c7943675f932b5e631b98fd5
MD5 cbf09cd5c6ff0669c09ea9e0c4eafc29
BLAKE2b-256 8c2e371a9959a59677e098f937164dcaf364c6630f7b946c1b77ca5815cf04ac

See more details on using hashes here.

File details

Details for the file ksalf-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: ksalf-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.3

File hashes

Hashes for ksalf-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8ba57979c52883fb7d2c1052fff24ba027f10658682f930f4f7b2b00c7f3f72f
MD5 69468c4bc627ab3d0102a5cd2b023910
BLAKE2b-256 cb4fd50ddb878f374ced245f0d5b281620e76b07bf24a89c59fcc0588d709be8

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