Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/python
from flask import Flask, request
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def home():
text = None
if request.method == 'POST':
if request.form['submit']:
text = "%s" % request.form['submit']
text = request.form['text']
page = """<h1>Flask Test Server</h1>
<form name='main' method='post'>
<p>
Enter Text: <input type='text' name='text'>
<input type='submit' value='submit' name='submit'>
</p>"""
if text:
return "%s<h2>%s</h2>" % (page, text)
return page
if __name__ == '__main__':
app.debug = True
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.