Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. from flask import Flask, request
  2. from flask.ext.restful import Resource, Api, reqparse
  3.  
  4. app = Flask(__name__)
  5. api = Api(app)
  6.  
  7. todos = {}
  8.  
  9. class TodoSimple(Resource):
  10.     def get(self, id):
  11.         return {id: todos[id]}
  12.  
  13.     def put(self, id):
  14.         todos[id] = request.form['data']
  15.         return {id: todos[id]}
  16.  
  17. class Main(Resource):
  18.     def get(self):
  19.         parser = reqparse.RequestParser()
  20.         parser.add_argument('rate', type=int, help='Rate to charge for this resource')
  21.         args = parser.parse_args()
  22.         return todos
  23.  
  24. api.add_resource(TodoSimple, '/<int:id>')
  25. api.add_resource(Main, '/')
  26.  
  27. if __name__ == '__main__':
  28.     app.run(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement