# Twig 0.5.0
Twig is a backend web framework for python utilizing the **socket** module to handle http requests and serve responses.
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 Response
app = 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("""<form action="/page/2">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>""")
@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()
```
Raw data
{
"_id": null,
"home_page": "https://github.com/FrewtyPebbles/Twig-Web-Framework",
"name": "TwigWeb",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "William Lim",
"author_email": "William.Lim@csu.fullerton.edu",
"download_url": "https://files.pythonhosted.org/packages/6a/d2/11366e281833461c47a012b8521bc4896420141faa4deacca85da4d89e78/TwigWeb-0.5.1.tar.gz",
"platform": null,
"description": "# Twig 0.5.0\n\nTwig is a backend web framework for python utilizing the **socket** module to handle http requests and serve responses.\n\nTo install use the following command:\n```cli\npy -m pip install TwigWeb\n```\n\n### Changelog\n\n---\n\n**0.5.0**\n\n - Fixed dynamic router.\n\n - Implemented URL query parameters.\n\n - Implemented Headers class to separate parts of incoming request for the developer.\n\n---\n\n**0.4.0**\n\n - Added dynamic route parameters.\n\n - Improved route handling with Route class\n\n---\n\n**0.3.0**\n\n - Added static paths and folders functions.\n\n - Added element class.\n\n - Added component classes.\n\n---\n\n**0.2.0**\n\n - Added `set_all_routes` function\n\n - Fixed inconsistent request handling\n\n - Improved documentation\n\n---\n\n### Example\n\nThis example does not show all of the functionality of Twig. There is documentation currently being worked on.\n\n```py\nfrom src.TwigWeb.backend.routehandler.route import Route, RouteParameter, RouteParamType\nfrom src.TwigWeb.backend import Server\nfrom src.TwigWeb.backend.response import Response\n\napp = Server(\"\", debug=True, open_root=False)\n\n@app.route(\"\")\ndef index(headers):\n #this is the index of the app\n return Response(\"test\", ContentType.html)\n\n@app.route(\"form\")\ndef form(headers):\n #this form redirects to page/2\n return Response(\"\"\"<form action=\"/page/2\">\n<label for=\"fname\">First name:</label><br>\n<input type=\"text\" id=\"fname\" name=\"fname\" value=\"John\"><br>\n<label for=\"lname\">Last name:</label><br>\n<input type=\"text\" id=\"lname\" name=\"lname\" value=\"Doe\"><br><br>\n<input type=\"submit\" value=\"Submit\">\n</form>\"\"\")\n\n@app.route(\"page/[num]\")\ndef index(headers, num):\n # Headers.URL is a dictionary containing all url query parameters/variables.\n # num a dynamic route.\n return Response(f\"num: {num} and {headers.URL}\", ContentType.html)\n\n@app.route(\"page\")\ndef index(headers):\n return Response(f\"page\", ContentType.html)\n\napp.run()\n```\n\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Twig is a frontend and backend web framework utilizing the python socket module to serve http requests.",
"version": "0.5.1",
"project_urls": {
"Bug Tracker": "https://github.com/FrewtyPebbles/Twig-Web-Framework/issues",
"Homepage": "https://github.com/FrewtyPebbles/Twig-Web-Framework"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2af8a29a35f78d1799b7c26563d5cf868d332249c941efde13e62e73c8475b21",
"md5": "b3ce163c409b4e54a67266ea5e1ec3e8",
"sha256": "7a3ae59e775f259472219dbd6fe0f3e7ac6ae139fee26fb21d94a9cf49812d86"
},
"downloads": -1,
"filename": "TwigWeb-0.5.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b3ce163c409b4e54a67266ea5e1ec3e8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 10531,
"upload_time": "2023-09-19T00:26:44",
"upload_time_iso_8601": "2023-09-19T00:26:44.378546Z",
"url": "https://files.pythonhosted.org/packages/2a/f8/a29a35f78d1799b7c26563d5cf868d332249c941efde13e62e73c8475b21/TwigWeb-0.5.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6ad211366e281833461c47a012b8521bc4896420141faa4deacca85da4d89e78",
"md5": "2439c1ff72e94a49d60138821a6c8fae",
"sha256": "fc123275edc97bff95c5a33371f138f11960f09afcc50b4d01d9fd3d6a465d6b"
},
"downloads": -1,
"filename": "TwigWeb-0.5.1.tar.gz",
"has_sig": false,
"md5_digest": "2439c1ff72e94a49d60138821a6c8fae",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 8525,
"upload_time": "2023-09-19T00:26:46",
"upload_time_iso_8601": "2023-09-19T00:26:46.128526Z",
"url": "https://files.pythonhosted.org/packages/6a/d2/11366e281833461c47a012b8521bc4896420141faa4deacca85da4d89e78/TwigWeb-0.5.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-19 00:26:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "FrewtyPebbles",
"github_project": "Twig-Web-Framework",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "twigweb"
}