Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help to use TORNADO in PYTHON. I have written a small code, but suppose, after making this a simple page, I want to

I need help to use TORNADO in PYTHON.

I have written a small code, but suppose, after making this a simple page, I want to count up every single time someone requests to visit the page. Every time the page is refreshed will give the correct number, it shouldn't need to be dynamically. What should I add? Kindly write comment to explain also. And If I have to make new file to do that then please say in details. I am new in this area.

I have copied the program I wrote-

from tornado import httpserver from tornado import gen from tornado.ioloop import IOLoop import tornado.web

class MainHandler(tornado.web.RequestHandler): def get(self): self.write("Hello World")

class HtmlHandler(tornado.web.RequestHandler): def initialize(self, ref_object = None): self.ref_object = ref_object def get(self): self.render('firstPage.html')

class App(tornado.web.Application):

def __init__(self): handlers = [ (r"/?", MainHandler), (r"/html/?", HtmlHandler) ] tornado.web.Application.__init__(self, handlers)

def main(): a = App() a.listen(8888) IOLoop.instance().start()

if __name__ == '__main__': main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Recognize the power of service guarantees.

Answered: 1 week ago

Question

Demonstrate how to use the Gaps Model for diagnosing and

Answered: 1 week ago