Building a Web App

For Practical Programming Class #3.

We’re going to build a web based quiz game today using Python 3 and a library called flask.


We may need to install pip which we can do with this command.

python3 -m pip install flask

You need to have python 3.4 or greater.

Starting out

Let’s make a folder for our project

mkdir webs and

cd webs

Create a python file (call it with the following text.

from flask import Flask
app = Flask(__name__)

def hello_world():
    return 'Hello'

if __name__ == '__main__':

Now run the file.


The template

<!DOCTYPE html>
<html lang="en">
    <form action="/game/" method="POST">
        <input type="text" name="text">
        <input type="submit" name="my-form" value="Send">