Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frewtypebbles/twig-web-framework
A tiny web framework that utilizes the python standard library socket module to handle HTTP requests.
https://github.com/frewtypebbles/twig-web-framework
decorator framework minimal python tiny twig web
Last synced: 3 days ago
JSON representation
A tiny web framework that utilizes the python standard library socket module to handle HTTP requests.
- Host: GitHub
- URL: https://github.com/frewtypebbles/twig-web-framework
- Owner: FrewtyPebbles
- License: mit
- Created: 2023-02-01T06:45:00.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-06-12T22:25:57.000Z (7 months ago)
- Last Synced: 2025-01-01T22:05:01.427Z (21 days ago)
- Topics: decorator, framework, minimal, python, tiny, twig, web
- Language: Python
- Homepage:
- Size: 121 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Twig 0.5.0
Twig is a backend web framework for python utilizing the **socket** module to handle http requests and serve responses.
***IMPORTANT***
> This framework is something I made to use myself as a tool and is not recommended for production.To install use the following command:
```cli
py -m pip install TwigWeb
```### Changelog
---
**0.5.0**
- Fixed dynamic router.
- Implemented URL query parameters.
- Implemented Headers class to separate parts of incoming request for the developer.
---
**0.4.0**
- Added dynamic route parameters.
- Improved route handling with Route class
---
**0.3.0**
- Added static paths and folders functions.
- Added element class.
- Added component classes.
---
**0.2.0**
- Added `set_all_routes` function
- Fixed inconsistent request handling
- Improved documentation
---
### Example
This example does not show all of the functionality of Twig. There is documentation currently being worked on.
```py
from src.TwigWeb.backend.routehandler.route import Route, RouteParameter, RouteParamType
from src.TwigWeb.backend import Server
from src.TwigWeb.backend.response import Responseapp = Server("", debug=True, open_root=False)
@app.route("")
def index(headers):
#this is the index of the app
return Response("test", ContentType.html)@app.route("form")
def form(headers):
#this form redirects to page/2
return Response("""
First name:
Last name:
""")
@app.route("page/[num]")
def index(headers, num):
# Headers.URL is a dictionary containing all url query parameters/variables.
# num a dynamic route.
return Response(f"num: {num} and {headers.URL}", ContentType.html)@app.route("page")
def index(headers):
return Response(f"page", ContentType.html)app.run()
```