Skip to main content

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:

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.

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()

Metadata

Release files for TwigWeb 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for TwigWeb 0.5.1
File Size Uploaded
TwigWeb-0.5.1.tar.gz 8.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for TwigWeb 0.5.1
File Interpreter ABI Platform
TwigWeb-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.1 kB

Release files / TwigWeb-0.5.1.tar.gz

Download URL TwigWeb-0.5.1.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fc123275edc97bff95c5a33371f138f11960f09afcc50b4d01d9fd3d6a465d6b
BLAKE2b-256 checksum
How to use checksums
6ad211366e281833461c47a012b8521bc4896420141faa4deacca85da4d89e78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.16 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9

Release files / TwigWeb-0.5.1-py3-none-any.whl

Download URL TwigWeb-0.5.1-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a3ae59e775f259472219dbd6fe0f3e7ac6ae139fee26fb21d94a9cf49812d86
BLAKE2b-256 checksum
How to use checksums
2af8a29a35f78d1799b7c26563d5cf868d332249c941efde13e62e73c8475b21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.16 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.17

2 release files

0.4.16

2 release files

0.4.15

2 release files

0.4.14

2 release files

0.4.13

2 release files

0.4.12

2 release files

0.4.11

2 release files

0.4.10

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page