The simplest Python WSGI example I could come up with

Today was my first day ever writing Python code. It’s pretty simple. I see why people like it. But when it comes to writing a web-based WSGI application, things get a little weird.

I looked all over for a simple “Hello, World” WSGI example. I found none. So here’s one, if it helps:

First, make a setup.py file. It should look something like this:

Next, write a wsgi.py file. This would be sort of (very roughly) like a controller that you might see in an enterprise app. Here’s a starter:

Want it to actually handle something like… I dunno… a URL? Consider this more elaborate example:

By the way, if you’re new to Python and need an IDE as a crutch (and you’re familiar with IntelliJ), try PyCharm.

Good luck out there.

Leave a Reply

Your email address will not be published. Required fields are marked *