Skip to content

Instantly share code, notes, and snippets.

@kaveenr
Created May 13, 2014 03:42
Show Gist options
  • Save kaveenr/18856df8d2337ab115b5 to your computer and use it in GitHub Desktop.
Save kaveenr/18856df8d2337ab115b5 to your computer and use it in GitHub Desktop.
Python3 Flask GET request
from flask import Flask , render_template , request
app = Flask(__name__)
app.debug = True
@app.route('/')
def hello():
return "<h1>Hello World </h1>"
@app.route('/hello/<name>')
def name(name=None):
if name:
return render_template("hello.html",name = name)
else:
return "<h1>Where is your name?</h1>"
@app.route('/meth',methods=['POST','GET'])
def showi():
if request.method == "GET":
return "<h1>Hello "+request.args.get("name","None")+"</h1>"
else:
return "<h1>Hey</h1>"
if __name__ == '__main__':
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment