Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, request
- from flask.ext.restful import Resource, Api, reqparse
- app = Flask(__name__)
- api = Api(app)
- todos = {}
- class TodoSimple(Resource):
- def get(self, id):
- return {id: todos[id]}
- def put(self, id):
- todos[id] = request.form['data']
- return {id: todos[id]}
- class Main(Resource):
- def get(self):
- parser = reqparse.RequestParser()
- parser.add_argument('rate', type=int, help='Rate to charge for this resource')
- args = parser.parse_args()
- return todos
- api.add_resource(TodoSimple, '/<int:id>')
- api.add_resource(Main, '/')
- if __name__ == '__main__':
- app.run(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement