Hariharan Srinath

Hello World Web Servers in Python & Go

Note: This is a simple post primarily written to learn markdown

Hello World programs are the first programs typically introduced in any programming language tutorial. However, in our modern era of web applications they are not particularly insightful into the strenghts of a language to support web development. In this article, we compare Hello World web servers written in Python & Go languages.

Go Language

The Go Language released by Google is notable for its terse C Language inspired syntax (indeed Ken Thompson that nevertheless removes a lot of boilerplate. It has a unique approach to concurrency and derives high performance from being a compiled language.

Go comes with extensive support for developing web applications within its standard library including a robust templating solution. For serving simple static or dynamic driven websites, onerarely need anything more than this. For fancier applications, third party libraries provide more complex routers, context packages etc. The Hello World web server is effectively just 3 lines of code and can support many concurrent connections.

package main

import (

func main() {
    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, "Hello World")
    log.Fatal(http.ListenAndServe(":8080", nil))


Python is among the simplest of modern programming languages to learn due to its guiding philosophy of There should be one and preferably only one obvious way to do it. Python’s ease and a large base of mature third party libraries has made it a language of choice among startups looking to iterate their minimum viable product quickly accepting the performance penalty of an interpreted language.

Python’s standard library has been designed for a prior era and it is definitely not as simple to spin up a Hello World webserver as in Go.

import BaseHTTPServer

HOST_NAME = 'localhost'

class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    def do_GET(s):
        s.send_header("Content-type", "text/text")
        s.wfile.write("Hello World")

if __name__ == '__main__':
    server_class = BaseHTTPServer.HTTPServer
    httpd = server_class((HOST_NAME, PORT_NUMBER), MyHandler)
    except KeyboardInterrupt:

However modern web development with Python typically relies on one of the many third party web frameworks, notably Django, to speed up web development. As an example, look at the simplification coming from the popular Flask micro-framework. However, Python’s lack of in-built support for easy concurrency means that often, jury-rigged solutions need to be employed in production to scale

from flask import Flask
app = Flask(__name__)

def hello():
    return "Hello World!"

if __name__ == "__main__":
comments powered by Disqus