I am using Klein to develop REST endpoints. (similar to Python Flask) I am interested in how can I pass parameters to the HTML file I want to serve, if that is even possible.
from twisted.web.static import File
from klein import Klein
app = Klein()
@app.route('/', branch=True)
def pg_index(request):
return File('./')
app.run("localhost", 8080)
Use a templating language such as Jinja or Chameleon. You could return a dictionary and interact with the dictionary on the template.
Klein's docs describe how to use Twisted templates.
and this, which shows you exactly what you are asking for. To quote the first few paragraphs: