GET & POST
Source: 13-Flask/flask/getpost.py
Start here — no coding background needed
What you will learn
GET reads data from URL; POST sends form data securely.
In simple words
Search uses GET. Login forms often use POST.
Build websites with Python — read for overview; run full apps on your computer later.
Easy example — run this first. Change values and press Run again.
Runs in your browser via Pyodide — no server. First run may take a few seconds.
Reference notes (from full bootcamp)
Optional — deeper detail for when you are ready
Reference script from the bootcamp repo. Read the code below; run a simplified version in the playground when marked runnable.
from flask import Flask,render_template,request
'''
It creates an instance of the Flask class,
which will be your WSGI (Web Server Gateway Interface) application.
'''
###WSGI Application
app=Flask(__name__)
@app.route("/")
def welcome():
return "<html><H1>Welcome to the flask course</H1></html>"
@app.route("/index",methods=['GET'])
def index():
return render_template('index.html')
@app.route('/about')
def about():
return render_template('about.html')
@app.route('/form',methods=['GET','POST'])
def form():
if request.method=='POST':
name=request.form['name']
return f'Hello {name}!'
return render_template('form.html')
@app.route('/submit',methods=['GET','POST'])
def submit():
if request.method=='POST':
name=request.form['name']
return f'Hello {name}!'
return render_template('form.html')
if __name__=="__main__":
app.run(debug=True)Browser practice only — full example needs Python on your computer (files, Flask, threads, etc.).
Practice test — try yourself
Write code, press Check. Wrong answer shows the correct code to copy & run.
You learned "GET & POST". Use print() to show: Done: GET & POST
Hint: Use one print() with the exact text.