Created
April 9, 2022 07:40
-
-
Save omar2205/c775d1f45cd189067c73dbb155e38fb3 to your computer and use it in GitHub Desktop.
this should work. Flask hello world
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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