todo_list.py 516 B

1234567891011121314151617181920212223
  1. #!/bin/env python
  2. from flask import Flask, request
  3. from flask_restful import Resource, Api
  4. app = Flask(__name__)
  5. api = Api(app)
  6. # This isn't available when run from gunicorn
  7. todos = {}
  8. class TodoSimple(Resource):
  9. def get(self, todo_id):
  10. return {todo_id: todos[todo_id]}
  11. def put(self, todo_id):
  12. todos[todo_id] = request.form['data']
  13. return {todo_id: todos[todo_id]}
  14. api.add_resource(TodoSimple, '/<string:todo_id>')
  15. if __name__ == '__main__':
  16. app.run(port=11022,debug=True)