flask allow all origin

This commit is contained in:
Florian Bezannier
2020-12-07 17:18:09 +01:00
parent fd44f29e5b
commit 6c4dc1958b
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -35,6 +35,7 @@ class ChargeControls:
for vin, el in chd.items():
charge_control_list.list[vin] = ChargeControl(psacc,vin,**el)
return charge_control_list
def get(self,vin):
try:
return self.list[vin]
+6
View File
@@ -81,6 +81,12 @@ def charge_control():
def get_recorded_position():
return FlaskResponse(myp.get_recorded_position(), mimetype='application/json')
@app.after_request
def after_request(response):
header = response.headers
header['Access-Control-Allow-Origin'] = '*'
return response
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("-f", "--config", help="config file", type=argparse.FileType('r'))