Skip to content

Instantly share code, notes, and snippets.

@CodingKoopa
Created March 29, 2026 05:19
Show Gist options
  • Select an option

  • Save CodingKoopa/b9f49e2e3894322408fb6e268cd7bf9f to your computer and use it in GitHub Desktop.

Select an option

Save CodingKoopa/b9f49e2e3894322408fb6e268cd7bf9f to your computer and use it in GitHub Desktop.
HackBU 2024 Flask Workshop
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>
My Website
</h1>
<p>
Hello! Make sure you <strong>do not</strong> click <a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">this link</a>.
</p>
<form method="POST">
<label for="name">Name</label>
<input id="name" name="name" />
<br />
<label for="feedback">Feedback</label>
<textarea id="feedback" name="feedback"></textarea>
<br />
<input type="submit" value="Submit!" />
</form>
<h2>Reviews</h2>
{% for comment in comments %}
<p>{{ comment.name }} says: {{ comment.feedback }}</p>
{% endfor %}
</body>
</html>
from flask import Flask, redirect, render_template, request
# Initialize Flask.
app = Flask('app', template_folder='.')
comments = []
@app.route('/', methods=["POST", "GET"])
def hello_world():
if request.method == 'POST':
comments.append({
'name': request.form['name'],
'feedback': request.form['feedback']
})
return redirect('/')
return render_template('index.html', comments=comments)
# Host the server.
app.run(host='0.0.0.0', port=5000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment