Giter VIP home page Giter VIP logo

ksalf's Introduction

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

ksalf's People

Contributors

haegi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.