Skip to content

Commit

Permalink
coding coffee episode 3
Browse files Browse the repository at this point in the history
  • Loading branch information
frncspeck committed Nov 2, 2022
1 parent 36e2693 commit 9a3f015
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
17 changes: 14 additions & 3 deletions flask_app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@

# A very simple Flask Hello World app for you to get started with...
import os
from flask import Flask, render_template, request
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField
from wtforms.validators import DataRequired

from flask import Flask
class MyForm(FlaskForm):
name = StringField('name', validators=[DataRequired()])
password = PasswordField('password', validators=[DataRequired()])

app = Flask(__name__)
app.config['SECRET_KEY'] = os.urandom(12).hex()

@app.route('/')
@app.route('/', methods=['GET', 'POST'])
def hello_world():
return "Hello from Between2Cracks!"
form = MyForm()
if request.method == 'POST':
print(form.name.data, form.password.data)
return render_template('form.html', form=form)

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Flask==2.1.2
Flask-WTF==1.0.1
12 changes: 12 additions & 0 deletions templates/form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html>
<head></head>
<body>
<h1>Hello, Between2Cracks!</h1>
<form method="POST" action="/">
{{ form.csrf_token }}
{{ form.name.label }} {{ form.name(size=20) }}
{{ form.password.label }} {{ form.password(size=20) }}
<input type="submit" value="Go">
</form>
</body>
</html>

0 comments on commit 9a3f015

Please sign in to comment.