Basic web app
This commit is contained in:
parent
f988943dbd
commit
7fbf3cb2bd
|
@ -0,0 +1 @@
|
|||
.idea
|
|
@ -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()
|
|
@ -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
|
|
@ -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>
|
Loading…
Reference in New Issue