Skip to content

Instantly share code, notes, and snippets.

@saikpr
Created March 30, 2016 17:29
Show Gist options
  • Save saikpr/5942f836f58cd14faf5822376870ea20 to your computer and use it in GitHub Desktop.
Save saikpr/5942f836f58cd14faf5822376870ea20 to your computer and use it in GitHub Desktop.
#!/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