A web framework module made by vinkami
Project description
Kripweb
This is a new web framework made by vinkami from the krippars
P.S. I wil make the doc page very soon because I think I will not be able to remember all the functions very quick. Blame me if the doc is not there.
Notes
Basically it's just a web framework like everyone expects.
Currently, it's more like flask than another separate framework cuz flask is just objectively nice and easy to use and easy to get similar of, except this is more suitable to be used in asgi, like quart.
Therefore, if you know how to write in flask, you're 90% gonna know how to write in kripweb.
How to use
Here is a basic script you may write and let it run correctly.
from kripweb.handler import Handler
from kripweb.response import TextResponse, StaticResponse, HTMLResponse
from uvicorn import run
handler = Handler()
@handler.page("")
async def home():
return HTMLResponse.render("main.html")
@handler.page("a", take_request=True)
async def a(request):
return TextResponse(request.query_string)
@handler.page("favicon.ico")
async def favicon():
return StaticResponse("logo.png")
@handler.error_page(404, take_request=True)
async def error404(request):
return TextResponse(f"Nope, {request.scope['path']}")
run(handler.application)
I think you can get it by its look, but I'll explain.
The handler
is the core of the module and everything will run with it.
handler.page()
is a decorator function that tells the handler
(or precisely, handler.application
) what to look for when getting a HTTP request of a page.
In addition, the functions' name actually doesn't matter, but you can use it tp do redirections.
handler.error_page()
allows you to set the pages to load if it gets any errors, like 404 not found in this example.
Finally, this handler is not able to run itself currently, so uvicorn is used here to start the server (TODO: add an in-module server so that it does not depend on something else)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.