Basic web app

This commit is contained in:
notplants 2022-03-14 22:04:41 -06:00
parent f988943dbd
commit 7fbf3cb2bd
4 changed files with 48 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea

29
main.py Normal file
View File

@ -0,0 +1,29 @@
from flask import Flask, flash, redirect, render_template, request, session, abort
app = Flask(__name__)
@app.route("/")
def index():
return "Index!"
@app.route("/hello")
def hello():
return "Hello World!"
@app.route("/form")
def form():
return render_template(
'form.html',**locals())
@app.route('/form_post', methods = ['POST'])
def form_post():
if request.method == 'POST':
data = request.form
print("data: {}".format(data))
# TODO: save this data to a csv
# deploy this python app to server somewhere
# with a particular domain
return "form submitted"
if __name__ == "__main__":
app.run()

6
requirements.txt Normal file
View File

@ -0,0 +1,6 @@
click==8.0.4
Flask==2.0.3
itsdangerous==2.1.1
Jinja2==3.0.3
MarkupSafe==2.1.0
Werkzeug==2.0.3

12
templates/form.html Normal file
View File

@ -0,0 +1,12 @@
<div>
here is the simple web form, lets see how this works
<br>
<form action="/form_post" method="post">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="Test"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Something"><br><br>
<input type="submit" value="Submit">
</form>
</div>