A simple web framework built for learning purpose.
Project description
sixi-web 
A simple web framework built for learning purpose.
Installation
pip install sixi-web
Usage
-
Import the Sixi web api instance to route. If you’ve used Flask before, you'll find it easy.
# app.py from sixi_web import API, Middleware app = API(templates_dir="templates", static_dir="static") @app.route("/") @app.route("/home") def index(req, resp): resp.text = "Hello world" @app.route("/about") def about(req, resp): resp.text = "A vegetable dog passing by." @app.route("/hello/{name}") def hello(req, resp, name): resp.text = f"Hello, {name}" @app.route("/add/{a:d}/{b:d}") def add(req, resp, a, b): result = int(a) + int(b) resp.text = f"{a} + {b} = {result}" @app.route("/todo") class TodoResource: def get(self, req, resp): resp.text = "Get a task" def post(self, req, resp): resp.text = "Create a task" @app.route("/html") def html(req, resp): resp.html = app.template("index.html", context=dict(title="hi", name="kada")) @app.route("/text") def text(req, resp): resp.text = "This is plain text" @app.route("/json") def json(req, resp): resp.json = dict(content="this is json") @app.error_handler(AttributeError) def attributeerror_handler(req, resp, e): resp.text = f"I got it, {e}" class PrintingMiddleware(Middleware): def process_request(self, req): print(f"request: {req}\n\n") def process_response(self, req, resp): print(f"response: {resp}\n\n") app.add_middleware(PrintingMiddleware)
-
Run with any WSGI application server such as Gunicorn.
gunicorn app:app
Roadmap
Request handlerRoutingClass based viewUnit testsCITemplate supportCustom exception handlerStatic files servingMiddlewareCustom responsePypiORM- CD
- Authentication
- Demo app
- Cli
- Session and Cookies
Contributing
Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE
for more information.
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.
Source Distribution
sixi-web-0.1.4.tar.gz
(7.6 kB
view details)
Built Distribution
File details
Details for the file sixi-web-0.1.4.tar.gz
.
File metadata
- Download URL: sixi-web-0.1.4.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.0 CPython/3.9.6 Linux/5.8.0-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
b50d2693e50acba2f21997f8ef76f03549b06c5a0e437b69c1bdd9c7866c3d1f
|
|
MD5 |
a7150e48b2ff8624229666f1b9dd8d51
|
|
BLAKE2b-256 |
c3317233cb3d6db3e526689537f13179a05d235d299ee326b823653d505e752b
|
File details
Details for the file sixi_web-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: sixi_web-0.1.4-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.0 CPython/3.9.6 Linux/5.8.0-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
c9a825042e31e6a979bffcc703c4f1a94a94915e5129e0bbe35cd8ec5dba251b
|
|
MD5 |
16f2f189cf16b9ff5fd92a2f68c28d7f
|
|
BLAKE2b-256 |
3e880713093231dcc90832cf57c5ad8b46051bf6c6ee8bb5ed5a54c7e27eba40
|