Routed Webserver

Know where you belong.

Creating a webserver can be a little shitty from time to time. Even more so when you experienced web development.
This component will make setting up a webserver a little easier by giving you some tools we know. Routes, parsing etc.


Routes are defined as a dict in the routedefinition and first define the request-type and then the uri.
Prefixing a uri-member with a : converts it to a parameter and will be a wildcard that is then passed to the handler in the params dict. 

A route consists of a handler-method and a list of middleware.
Handler and middleware take a mutable request and responde and the server-comp object. 

Definitions:
class Request:
	method : str
	header : dict
	uri    : str
	params : dict
	query  : dict
	data   : any
	cookies: dict

class Response:
    statuscode : int
    statusreason : str
    header : dict
    cookies : list
    data : any



Parameters:
  • Active : Is the webserver active?
  • Restart : Restart the webserver.
  • Port: On which port should the server listen?
  • Create Routes: Creates an example route-definition.
  • Routes: The path to the routedefinition.

Attributes:
  • Cookie: The class definition for a new cookie to be attachable to the cookies-list of a response-object
    key : str    
    value : str
    same_site : str = "Strict"    
    max_age : int = 2592000

  • Exceptions : A module containing several exceptions that will return specific codes when raised.
    • BadRequest,
    • Unauthorized,
    • Forbidden,
    • NotFound,
    • MethodNotAllowed,
    • Gone,
    • InternalServerError,
    • NotImplemented,
    • BadGateway,
    • ServiceUnavailable,
    • GatewayTimeout 

Downloads: 1534

Created at: 6.8.2021

Uploaded: 6.7.2023
Proper headerparsing!
Download