From d5986309f18432038203794a1d737fe0fed55222 Mon Sep 17 00:00:00 2001 From: Ritwik Gupta Date: Mon, 27 Feb 2017 21:56:46 -0500 Subject: [PATCH] Add CORS headers to all routes --- apiwrapper/views.py | 5 ++--- requirements.txt | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apiwrapper/views.py b/apiwrapper/views.py index 9070522..35b72e1 100644 --- a/apiwrapper/views.py +++ b/apiwrapper/views.py @@ -17,13 +17,14 @@ ''' from flask import Flask, make_response from flask_restful import Api, Resource +from flask_cors import CORS, cross_origin from .PittAPI.PittAPI import course, lab, laundry, people, shuttle, textbook, news import json app = Flask(__name__) +CORS(app) api = Api(app) - @api.representation('application/json') def output_json(data, code, headers=None): """Makes a Flask response with a JSON encoded body""" @@ -135,8 +136,6 @@ def get(self, feed, max_news_items): return {'error': str(e)} - - api.add_resource(CourseGetAPI, '/courses//') api.add_resource(ClassAPI, '/class//') api.add_resource(LabStatusAPI, '/lab_status/') diff --git a/requirements.txt b/requirements.txt index b893573..61140f4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ beautifulsoup4 nose nose-cov nose-timer +flask-cors