Tornado Websocket

Dennis Moyo
1 min readSep 14, 2018

Lately i’ve been looking for an async web framework which will allow me to make async web apps in python. As you may know python servers are all blocking, meaning one event waits for another to finish before it starts. This of course is not a big problem unless you want to have a continuos process running without any on/off activity. After some searching i discovered Tornado web framework which is written in python. If you are not familiar with tornado, you can read more here: http://www.tornadoweb.org.

The main feature that i was interested in was the use of websockets. I wanted to see how exactly i could implement websockets and how they worked so i made a simple websocket server. Below is a tornado websocket server.py file which starts a server on port 8000.

For the client i normally use plain Javascript but you can use other websocket clients if you wish.

That’s it!! Runs server.py in command prompt then navigate to localhost:8000 in broswer. You should see a message in the console. This was just an introduction as there is a lot more you can do with this. That’s all for now!!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Dennis Moyo
Dennis Moyo

Written by Dennis Moyo

Programmer and lover of code

No responses yet

Write a response