liveBook · Manning

Web application

As explained in A Pythonic Adventure: From Python basics to a working web app

A web application is software that delivers interactive functionality through web technologies and is accessed using a web browser or other network client.

A web application gives people an interactive program in a browser. Instead of using an iPad as a paper notepad for coffee orders, a small coffee shop can offer a menu, accept a choice, and show the submitted order on a web page. Start small: one useful screen is already a real application. section 1.0 section 10.0

A running application listens at an address such as http://127.0.0.1:5000/. Open that URL in a browser to see it. In a Python setup, Flask supplies the application structure, while routes connect addresses such as /order to Python functions that decide which page to return. section 10.0

A first order-taking web application can work in a simple loop:

  • Show an HTML form with menu choices and a Submit button. section 10.0
  • Send the form to an /order route with a POST request. section 10.0
  • Read the submitted values in Python and pass them to a template. section 10.0 section 11.0
  • Display a friendly order-confirmation page, with a button for another order. section 10.0

A coffee menu that remembers orders

A fuller menu asks for a customer name, drink, flavor, and topping. The route gathers those fields into a dictionary, adds it to an orders list, and saves the list as orders.json. When the application starts again, it can load earlier orders before accepting new ones. That turns a nice-looking form into a useful shop tool. section 11.0 section 11.0

A web application is meant to keep running so it can respond whenever someone sends a request. This makes it different from a short text-mode program that finishes and stops. For an order system, staying available means the next customer can use the menu without restarting the program. section 11.0

Listing 10.1 The first menu form with two options
<html>
<body>
<form>
    <select>
      <option>Coffee</option>
      <option>Decaf</option>
    </select>
    <input type="submit" value="Submit">
</form>
</body>
</html>

Inspect the smallest useful interface: a select menu inside a form and a Submit button. Change the options, run the application, and see how the browser presents your choices. section 10.0

How A Pythonic Adventure: From Python basics to a working web app covers it

How deep it goes
Works through Flask setup, local URLs, forms, routes, templates, and JSON order storage without detailing deployment.
Examples
Uses a coffee-shop menu with drinks, flavors, toppings, customer names, confirmation pages, and an orders.json file.
What it assumes
Starts from zero programming experience while using Python and the Mu editor step by step.
What you can do after
Build it from scratch as a Flask coffee-order application that receives form data, confirms orders, and saves them.
How it connects
Connects Flask, URLs, HTML forms, HTTP GET and POST, routes, templates, JSON, and web services.

Also explained in

Compare how 8 books explain web application →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of A Pythonic Adventure: From Python basics to a working web app. The section links point to the parts of the book it draws on.