[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/mauricelambert/WebScripts/main/docs/Add_Module.md [Back]  [Original]

# Add Module ## Build the module Write in `./scripts/py/hello.py`: ```python def hello(environ, user, server, filename, arguments, inputs, csrf_token=None): return "200 OK", {"Content-Type": "text/plain"}, f"Hello {user.name} !" def page_500(error): return error, {"Content-Type": "text/html; charset=utf-8"}, [b"

ERROR 500



\n\n", error.encode()] def page_401(error): return error, {"Content-Type": "text/html; charset=utf-8"}, [b"

ERROR 401



\n\n", error.encode()] def page_403(error): return error, {"Content-Type": "text/html; charset=utf-8"}, [b"

ERROR 403



\n\n", error.encode()] def page_404(error): return error, {"Content-Type": "text/html; charset=utf-8"}, [b"

ERROR 404



\n\n", error.encode()] ``` ## Add configuration In a *server configuration file* in `server` section (using `INI` syntax): ```ini modules=hello modules_path=./scripts/py ``` ## Load configurations Restart the server. ## Get the pages Open your web browser on `http://127.0.0.1:8000/hello/hello/`. To test custom page for error 404: `http://127.0.0.1:8000/hello/`. To test custom page for error 403: `http://127.0.0.1:8000/api/scripts/view_users.py`. To test custom page for error 500: `http://127.0.0.1:8000/get/`.
Web Proxy Viewer  |  New URL  |  Original Page