spiderweb/example.py
2024-08-06 01:10:00 -04:00

24 lines
559 B
Python

from spiderweb import WebServer
from spiderweb.response import HttpResponse, JsonResponse, TemplateResponse, RedirectResponse
app = WebServer(templates_dirs=["templates"])
@app.route("/")
def index(request):
return TemplateResponse(request, "test.html", context={"value": "TEST!"})
@app.route("/redirect")
def redirect(request):
return RedirectResponse("/")
if __name__ == "__main__":
# app.add_route("/", index)
try:
app.start()
print("Currently serving on", app.uri())
except KeyboardInterrupt:
app.stop()