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