Python Tornado dynamic html

0

(en) I am doing some test in python with tornado, I am trying to pass some code to html from python, follow th code:

(en) I'm doing some tests in Python with the library become, I'm trying to pass part of the HTML code by the python code, follow code.

  

Monthly Code.html

<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>

<select name="mymenu">
    {% for i in options %}
        {{ i }}
    {% end %}
</select>

</body>
</html>
  

(en) Webserver code

import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        opt=[ "<option value=\"1\">Option One</option>","<option value=\"2\">Option Two</option>","<option value=\"3\">Option Three</option>"]
        self.render('mensal.html', options=opt)

def make_app():
    return tornado.web.Application([
        (r"/", MainHandler),
    ])

if __name__ == "__main__":
    app = make_app()
    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()
  

(en) But the html output is (part of the code):   (en) But the output in html is:

<select name="mymenu">

&lt;option value="1"&gt;Option One&lt;/option&gt;

&lt;option value="2"&gt;Option Two&lt;/option&gt;

&lt;option value="3"&gt;Option Three&lt;/option&gt;

</select>
    
asked by anonymous 13.10.2018 / 04:34

0 answers