Search code examples
pythonpycharmtornado

Debug Tornado Web Server in Pycharm


Is there anyone who can debug the code run in Tornado Web Server in Pycharm?

I searched the question in google, but I can not found the answer.


Solution

  • Here are the steps I used:

    • In your PyCharm project, create a new Python file called tornado_test.py and paste the contents of the hello world example on Tornado's docs.
    • Right click on the newly created file and select Debug 'tornado_test'
    • Create a breakpoint on line 13 ( self.write("Hello, world") ) using left-click next to the line number
    • Open a browser and go to http://127.0.0.1:8888/ (it should start waiting for a response)
    • Go back to PyCharm and your breakpoint should be activated (you can now debug the code, see variables such as request for example)

    Screenshot (don't worry about the blurred parts - those are just other files I had in my project):

    enter image description here

    Of course you need to have Tornado installed in the (virtual) Python environment you use in PyCharm.