I have two HTML files( Home1.html and Home2.html ). I want to merge these two HTML files and serve it as one page using Tornado framework. But I get an error :"Runtime Error: Cannot render() after finish()
" when I tried the following:
class Setup(tornado.web.RequestHandler):
def get(self):
self.render("Home1.html")
self.render("Home2.html")
application = tornado.web.Application([
(r"/setup",Setup ),
])
if __name__ == "__main__":
application.listen(5500)
tornado.ioloop.IOLoop.instance().start()
You'll have to learn how templating works. Read this page on the docs to learn more: http://www.tornadoweb.org/en/stable/guide/templates.html#template-syntax
After that, you can find the complete template syntax reference on this page: http://www.tornadoweb.org/en/stable/template.html#syntax-reference
Anyway, you can "merge" two templates and render them as one by using the {% include %}
template tag. Example:
Your Home1.html
template should look roughly like this:
<html>
<!-- do something -->
{% include 'Home2.html' %}
<!-- do something else -->
</html>
Then render only the Home1.html
from your request handler.
This answer is far from perfect. You'll have to invest some time to actually learn about templates.