Skip to content

Instantly share code, notes, and snippets.

@omar2205
Created April 9, 2022 07:40
Show Gist options
  • Save omar2205/c775d1f45cd189067c73dbb155e38fb3 to your computer and use it in GitHub Desktop.
Save omar2205/c775d1f45cd189067c73dbb155e38fb3 to your computer and use it in GitHub Desktop.
this should work. Flask hello world
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def hello():
# respond only if the method is POST
# i.e. user clicked submit
if request.method == 'POST':
name=request.form.get('name', 'world')
return f'hello {name}'
# otherwise respond with the form
return '''
<form action="/" method="POST">
<input name="name" />
<input type="submit">
</form>
'''
if __name__ == '__main__':
app.run(host='0.0.0.0', port=3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment