Skip to content

Instantly share code, notes, and snippets.

@d4n13lbc
Created April 19, 2017 13:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save d4n13lbc/a8f4cbc0831ed720ef69026645009a7b to your computer and use it in GitHub Desktop.
import json
from flask import Flask, abort, request
from flask_restplus import Resource, Api
from users_commands import get_all_users, add_user, remove_user
app = Flask(__name__)
api = Api(app,version='1.0', title='API for users management', description='A demonstration of a Flask RestPlus powered API')
ns = api.namespace('v1.0/users', description='Operations related to create users')
@ns.route('/')
class UserCollection(Resource):
@api.response(200, 'List of users successfully returned.')
def get(self):
""" returns a list of users """
list = {}
list["users"] = get_all_users()
return json.dumps(list), 200
if __name__ == "__main__":
app.run(host='0.0.0.0',port=8088,debug='True')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment