Files
PyWebServer/PES.md
T
Bill Gates 3276224943 Version 0.3.0
Enhanced multithreading engine, bugs fixed and more!
2026-08-07 15:06:13 +02:00

1.0 KiB

PES

This is a quick reference document on how to implement PES.

Example script:

The default script is the following:

import sys
import os

if not os.getcwd() in sys.path:
    sys.path.append(os.getcwd())
import amethyst


class PES:
    """
    class
    """

    def __init__(self):
        # DO NOT USE THIS CLASS FOR PROGRAM, ONLY ON_REQUEST PLEASE!!
        # Below go definitions to get things working.
        self.build_response = amethyst.WebServer.build_binary_response
        self.fh = amethyst.FileHandler("..")
        self.rq = amethyst.RequestParser()
        # NOTE: THREAD_SAFETY is a required setting, as it defines
        # if it can run within the Amethyst thread pool or needs to
        # run independently
        # False = run independent. True = run in Amethyst thread pool.
        self.THREAD_SAFETY: bool = False

    def on_request(self, req):
        return self.build_response(200, "This is a test", "text/html")

if __name__ == "__main__":
    # Code to run if it is not thread-safe.
    PES.on_request(PES, "request")