@@ -68,26 +68,31 @@ def get(self, todo_id):
68
68
# This goes into the summary
69
69
"Get a todo task"
70
70
abort_if_todo_doesnt_exist (todo_id )
71
- return TODOS [todo_id ]
71
+ return TODOS [todo_id ], 200 , { 'Access-Control-Allow-Origin' : '*' }
72
72
73
73
def delete (self , todo_id ):
74
74
abort_if_todo_doesnt_exist (todo_id )
75
75
del TODOS [todo_id ]
76
- return '' , 204
76
+ return '' , 204 , { 'Access-Control-Allow-Origin' : '*' }
77
77
78
78
def put (self , todo_id ):
79
79
args = parser .parse_args ()
80
80
task = {'task' : args ['task' ]}
81
81
TODOS [todo_id ] = task
82
- return task , 201
82
+ return task , 201 , { 'Access-Control-Allow-Origin' : '*' }
83
83
84
+ def options (self , ** args ):
85
+ return {'Allow' : 'GET,PUT,POST,DELETE' }, 200 , \
86
+ { 'Access-Control-Allow-Origin' : '*' , \
87
+ 'Access-Control-Allow-Methods' : 'GET,PUT,POST,DELETE' , \
88
+ 'Access-Control-Allow-Headers' : 'Content-Type' }
84
89
85
90
# TodoList
86
91
# shows a list of all todos, and lets you POST to add new tasks
87
92
class TodoList (Resource ):
88
93
89
94
def get (self ):
90
- return TODOS
95
+ return TODOS , 200 , { 'Access-Control-Allow-Origin' : '*' }
91
96
92
97
@swagger .operation (
93
98
notes = 'Creates a new TODO item' ,
@@ -118,7 +123,7 @@ def post(self):
118
123
args = parser .parse_args ()
119
124
todo_id = 'todo%d' % (len (TODOS ) + 1 )
120
125
TODOS [todo_id ] = {'task' : args ['task' ]}
121
- return TODOS [todo_id ], 201
126
+ return TODOS [todo_id ], 201 , { 'Access-Control-Allow-Origin' : '*' }
122
127
123
128
@swagger .model
124
129
class ModelWithResourceFields :
@@ -158,8 +163,9 @@ class MarshalWithExample(Resource):
158
163
responseClass = TodoItemWithResourceFields ,
159
164
nickname = 'get' )
160
165
@marshal_with (TodoItemWithResourceFields .resource_fields )
161
- def get (self ):
162
- return {}
166
+ def get (self , ** kwargs ):
167
+ return {}, 200 , {'Access-Control-Allow-Origin' : '*' }
168
+
163
169
164
170
##
165
171
## Actually setup the Api resource routing here
0 commit comments