Skip to content

Commit 685c7fd

Browse files
committed
fix cors issues
1 parent 1740c42 commit 685c7fd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

server/app.py

+14
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def save_settings(settings):
7373

7474

7575
@app.route("/save", methods=["POST"])
76+
@cross_origin(origin=client_url, headers=["Content-Type"])
7677
def save_annotate_info():
7778
try:
7879
request_data = request.get_json()
@@ -131,11 +132,13 @@ def save_settings(settings):
131132

132133

133134
@app.route("/settings", methods=["GET"])
135+
@cross_origin(origin=client_url, headers=["Content-Type"])
134136
def get_settings():
135137
return jsonify(initial_settings)
136138

137139

138140
@app.route("/settings", methods=["POST"])
141+
@cross_origin(origin=client_url, headers=["Content-Type"])
139142
def update_settings():
140143
new_settings = request.json
141144
initial_settings.update(new_settings)
@@ -144,6 +147,7 @@ def update_settings():
144147

145148

146149
@app.route("/settings/reset", methods=["POST"])
150+
@cross_origin(origin=client_url, headers=["Content-Type"])
147151
def reset_settings():
148152
global initial_settings
149153
initial_settings = default_settings.copy()
@@ -152,6 +156,7 @@ def reset_settings():
152156

153157

154158
@app.route("/upload", methods=["POST"])
159+
@cross_origin(origin=client_url, headers=["Content-Type"])
155160
def upload_file():
156161
try:
157162
uploaded_files = []
@@ -222,6 +227,7 @@ def delete_file(filename):
222227

223228

224229
@app.route("/activeImage", methods=["POST"])
230+
@cross_origin(origin=client_url, headers=["Content-Type"])
225231
def save_active_image_info():
226232
try:
227233
request_data = request.get_json()
@@ -338,6 +344,7 @@ def add_regions(regions, region_type=None):
338344

339345

340346
@app.route("/imagesName", methods=["POST"])
347+
@cross_origin(origin=client_url, headers=["Content-Type"])
341348
def images_name():
342349
try:
343350
data = request.get_json()
@@ -371,6 +378,7 @@ def clear_upload_folder():
371378

372379

373380
@app.route("/clearSession", methods=["POST"])
381+
@cross_origin(origin=client_url, headers=["Content-Type"])
374382
def clear_session():
375383
global initial_settings
376384
try:
@@ -385,6 +393,7 @@ def clear_session():
385393

386394

387395
@app.route("/download_configuration", methods=["POST"])
396+
@cross_origin(origin=client_url, headers=["Content-Type"])
388397
def download_configuration():
389398
try:
390399
data = request.get_json()
@@ -418,6 +427,7 @@ def download_configuration():
418427

419428

420429
@app.route("/class_distribution", methods=["POST"])
430+
@cross_origin(origin=client_url, headers=["Content-Type"])
421431
def class_distribution():
422432
try:
423433
class_data = dbModule.get_class_distribution()
@@ -435,6 +445,7 @@ def class_distribution():
435445

436446

437447
@app.route("/download_image_with_annotations", methods=["POST"])
448+
@cross_origin(origin=client_url, headers=["Content-Type"])
438449
def download_image_with_annotations():
439450
temp_dir = None # Initialize temporary directory variable
440451

@@ -740,6 +751,7 @@ def get_image_annotations():
740751

741752

742753
@app.route("/download_image_mask", methods=["POST"])
754+
@cross_origin(origin=client_url, headers=["Content-Type"])
743755
def download_image_mask():
744756
try:
745757
data = request.get_json()
@@ -1068,6 +1080,7 @@ def create_yolo_annotations(image_names, color_map=None):
10681080

10691081

10701082
@app.route("/download_yolo_annotations", methods=["POST"])
1083+
@cross_origin(origin=client_url, headers=["Content-Type"])
10711084
def download_yolo_annotations():
10721085
data = request.get_json()
10731086
image_names = data.get("image_names", [])
@@ -1120,6 +1133,7 @@ def download_yolo_annotations():
11201133

11211134

11221135
@app.route("/imagesInfo", methods=["GET"])
1136+
@cross_origin(origin=client_url, headers=["Content-Type"])
11231137
def get_images_info():
11241138
global path
11251139

0 commit comments

Comments
 (0)