Created
June 5, 2018 04:52
-
-
Save blackandred/518fc61fc9518d1df38d5cd42203e5e3 to your computer and use it in GitHub Desktop.
Tornado: Set CORS headers for every controller (use origin with * for dev environment and for internal services behind firewall)
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 tornado.web | |
# | |
# Created for Anarchist movement | |
# | |
# http://iwa-ait.org | |
# http://zsp.net.pl | |
# | |
class BaseHandler(tornado.web.RequestHandler): | |
def data_received(self, chunk): | |
pass | |
def set_default_headers(self): | |
self.set_header("Access-Control-Allow-Origin", "*") | |
self.set_header("Access-Control-Allow-Headers", "x-requested-with") | |
self.set_header('Access-Control-Allow-Methods', 'POST, PUT, GET, OPTIONS, DELETE') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment