ESP32 Web Server: Basic, WebServer, Async or Flask?

Quick answer

New to it? Build one with routes. Want a slider or live numbers? Async. Read the basic one once: it explains the others.

Side by side

Basic (WiFiServer)

Who it's for
Students who want to see how it works
Level
advancedintermediate
Cost
Medium
Main parts
ESP32 or ESP8266, 2 LEDs, 2 resistors
Wiring
Easy
Code
About 150 lines, all by hand
It can
Show every line of a web request
It can't
Grow easily: the HTML is mixed into the code

WebServer with routes

Who it's for
Ages 10+ after HTML for Gadgets
Level
intermediate
Cost
Medium
Main parts
ESP32, LED, fan or second LED
Wiring
Easy
Code
About 51 lines plus your own HTML page
It can
Keep your page separate, with one line per button
It can't
Update parts of the page without a little JavaScript

Async web server

Who it's for
Advanced
Level
advancedintermediate
Cost
Medium
Main parts
ESP32, LED (and DHT11 for one lesson)
Wiring
Easy
Code
About 117 to 152 lines and two extra libraries
It can
Sliders and live readings without reloading
It can't
Compile on ESP32 core 3 with the old .zip libraries

Flask on a Raspberry Pi

Who it's for
Python users
Level
intermediate
Cost
High
Main parts
Raspberry Pi
Wiring
None
Code
About 11 lines of Python
It can
Use the whole of Python
It can't
Switch a pin in this lesson: it's a Hello World page

Written from the parts lists and code in these tutorials. Cost is a rough guide to the parts they list, compared with each other; line counts are of the main program.

More comparisons