Tornado Tutorial


web development course

Tornado Tutorial - Learn how to build websites using Python

If you are not on the web then you are no where. These days you need to get your data on the web. This is by far the best way to share your analysis.


It can be through your company's intranet, a blog, or your own web site. Sharing your work through Excel, Word, or even PowerPoint is not enough!


You will be asked to create web applications that live on the net. They have to be able to read data from databases, show up on smart phones, and the end users have to be able to interact with it.


You can't start a business without a website, can you? Having a web presence is a great way to market yourself. Having the skills to put together a simple web page for your portfolio, resume, or start-up is very important.


Learning about HTML, CSS, and Javascript are useful web technologies that you need to have under your belt.


In the following sections we will take you through all the steps to get started building websites in Python and Tornado. Don't worry if you have no programming experience, we have written this guide assuming you are starting from ground zero.


Let's Get Started!


Copy the code below to your favorite text editor and save it as a .py file.


	# imports
	import tornado.ioloop
	import tornado.web

	# write to screen
	class MainHandler(tornado.web.RequestHandler):
		def get(self):
			self.write('Hello World!')

	# r"/" == root website address
	application = tornado.web.Application([
		(r"/", MainHandler)
	])

	# Start the server at port 7777
	if __name__ == "__main__":
		PortNumber = str(7777)
		print(r'Server Running at http://localhost:' + PortNumber + r'/')
		print(r'To close press ctrl + c')
		application.listen(PortNumber)
		tornado.ioloop.IOLoop.instance().start()
	

You should now have a file similar to the one below.


create python file

Click the Windows button and start typing command prompt as shown below.


open cmd prompt

Please click on the icon as shown below to start the Command Prompt.


run cmd prompt

Using the Command Prompt, type python + the file location of your app.py file as shown below to start the Tornado application. Note that you need to have Python and all associated Tornado libraries installed for this to work. If you are confused, please go to my Jupyter/IPython Notebook tutorial before continuing.


run file

If all goes well, you will see a message telling you that the server is running and the URL of the server as shown below. Yay!


server running

Navigate to http://localhost:7777 using Chrome or any other modern browser. If you see Hello World! printed in your browser as shown below, you have officially created your very first Python powered web site. Good Job!

hello world
Where Do I Go From Here?
concat

Enroll in the Free Tornado Tutorial Email Course at the top of this page

There is a lot more to Tornado than the Hello World application we just created. That is why I created the 5 part Tutorial series that will show you everything you need to start developing your own web sites using Python. All you need to do is go to the top of this page and sign up for the course to get started today.