Created
November 2, 2017 07:12
-
-
Save santosh/ec153ae4dca7099b5935af5c94e631e0 to your computer and use it in GitHub Desktop.
Return back user agent in Flask. #Python
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, request | |
app = Flask(__name__) | |
@app.route('/') | |
def index(): | |
user_agent = request.headers.get('User-Agent') | |
return '<p>Your browser is {}!</p>'.format(user_agent) | |
@app.route('/user/<name>') | |
def user(name): | |
return '<h1>Hello, {name}!</h1>'.format(name=name) | |
if __name__ == '__main__': | |
app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment