add cross origin to fix issues in browsers
This commit is contained in:
@@ -5,6 +5,7 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from flask import Flask, Response, request
|
from flask import Flask, Response, request
|
||||||
|
from flask_cors import CORS, cross_origin
|
||||||
from json import JSONEncoder
|
from json import JSONEncoder
|
||||||
|
|
||||||
from aman.AMAN import AMAN
|
from aman.AMAN import AMAN
|
||||||
@@ -37,10 +38,13 @@ with open(os.path.join(os.environ['AMAN_PATH'], 'VERSION')) as file:
|
|||||||
|
|
||||||
# initialize the web services
|
# initialize the web services
|
||||||
app = Flask('AMAN')
|
app = Flask('AMAN')
|
||||||
|
cors = CORS(app)
|
||||||
|
app.config['CORS_HEADERS'] = 'Content-Type'
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run()
|
app.run()
|
||||||
|
|
||||||
@app.route('/aman/airports')
|
@app.route('/aman/airports')
|
||||||
|
@cross_origin()
|
||||||
def airports():
|
def airports():
|
||||||
# get the airports
|
# get the airports
|
||||||
retval = []
|
retval = []
|
||||||
@@ -73,6 +77,7 @@ def newUser():
|
|||||||
return Response(data, status=200, mimetype='application/json')
|
return Response(data, status=200, mimetype='application/json')
|
||||||
|
|
||||||
@app.route('/aman/configuration/<icao>')
|
@app.route('/aman/configuration/<icao>')
|
||||||
|
@cross_origin()
|
||||||
def configuration(icao):
|
def configuration(icao):
|
||||||
airport = aman.findAirport(icao.upper())
|
airport = aman.findAirport(icao.upper())
|
||||||
if None == airport:
|
if None == airport:
|
||||||
@@ -105,6 +110,7 @@ def configuration(icao):
|
|||||||
return Response(data, status=200, mimetype='application/json')
|
return Response(data, status=200, mimetype='application/json')
|
||||||
|
|
||||||
@app.route('/aman/sequence/<icao>')
|
@app.route('/aman/sequence/<icao>')
|
||||||
|
@cross_origin()
|
||||||
def sequence(icao):
|
def sequence(icao):
|
||||||
airport = aman.findAirport(icao.upper())
|
airport = aman.findAirport(icao.upper())
|
||||||
if None == airport:
|
if None == airport:
|
||||||
@@ -125,6 +131,7 @@ def sequence(icao):
|
|||||||
return Response(data, status=200, mimetype='application/json')
|
return Response(data, status=200, mimetype='application/json')
|
||||||
|
|
||||||
@app.route('/aman/configure', methods=['POST'])
|
@app.route('/aman/configure', methods=['POST'])
|
||||||
|
@cross_origin()
|
||||||
def configure():
|
def configure():
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user