Created
March 30, 2016 17:29
-
-
Save saikpr/5942f836f58cd14faf5822376870ea20 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from flask import Flask, jsonify | |
#creating a Flask object | |
simple_api = Flask(__name__, static_folder='static') | |
#adding route | |
@simple_api.route("/hello/<user_name>",methods = ["GET"]) | |
def return_hello(user_name=None): | |
""" | |
SAMPLE URI : /hello/sainyam | |
returns | |
{ | |
"message": "Hello sainyam", | |
"status": "success" | |
} | |
""" | |
if user_name != None: | |
message = "Hello " + str(user_name) | |
else : | |
message = "Hello world" | |
#return a json | |
return jsonify({'message': message, | |
'status': 'success'}) | |
if __name__=="__main__": | |
#running the server | |
simple_api.run(debug=True, host="0.0.0.0",port=8081) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment