Last active
May 27, 2016 14:16
-
-
Save giwa/b54c4e7cfee8b21bc41584f5e4a4463a to your computer and use it in GitHub Desktop.
Falcon CORS ref: http://qiita.com/giwa/items/0385a6c90a1e712b00d7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import falcon | |
class CORSMiddleware: | |
def process_request(self, req, resp): | |
resp.set_header('Access-Control-Allow-Origin', '*') | |
class Todo: | |
def on_get(self, req, resp): | |
resp.status = falcon.HTTP_200 | |
resp.body = '{"foo":"bar"}' | |
api = application = falcon.API(middleware=[CORSMiddleware()]) | |
todo = Todo() | |
api.add_route('/todo', todo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTTP/1.1 200 OK | |
Connection: close | |
Date: Fri, 27 May 2016 07:14:46 GMT | |
Server: gunicorn/19.6.0 | |
access-control-allow-origin: * | |
content-length: 13 | |
content-type: application/json; charset=UTF-8 | |
{ | |
"foo": "bar" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment