From 4e9cd5593a2e48b045472fb5455666cd861056d2 Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Sat, 22 Jun 2024 22:29:19 +0100 Subject: [PATCH] add CORS rule for ANY origin --- app.py | 11 ++++++----- requirements.txt | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 2718559..6cce77a 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,5 @@ from flask import Flask +from flask_cors import CORS from flask_restx import Api, Resource from marshmallow import Schema, fields, validate from models import dice_model, ability_model, hp_model, character_model @@ -6,6 +7,8 @@ from mutations import Mutations import random app = Flask(__name__) +CORS(app) + app.config.SWAGGER_UI_JSONEDITOR = True app.config['SWAGGER_UI_JSONEDITOR'] = True api = Api(app, version='1.0', title='Gamma World Dice', description='Rolled Dice As A Service') @@ -229,7 +232,7 @@ def roll_mutations(conscore, intscore): """ mutations_table = {} - mental_mutations_cnt = roll_dices(1,4, False).get('result') + mental_mutations_cnt = roll_dices(1, 4, False).get('result') physical_mutations_cnt = roll_dices(1, 4, False).get('result') mutations_table['count'] = {'mental': mental_mutations_cnt, 'physical': physical_mutations_cnt} @@ -239,7 +242,7 @@ def roll_mutations(conscore, intscore): for _ in range(mental_mutations_cnt): mscore = roll_dices(1, 100, False).get('result') + intscore if mscore in mental_mutations_scores: - mscore = mscore-3 + mscore = mscore - 3 if mscore > 100: mscore = 100 @@ -248,7 +251,7 @@ def roll_mutations(conscore, intscore): for _ in range(physical_mutations_cnt): pscore = roll_dices(1, 100, False).get('result') + conscore if pscore in physical_mutations_scores: - pscore = pscore-3 + pscore = pscore - 3 if pscore > 100: pscore = 100 @@ -273,7 +276,5 @@ def roll_mutations(conscore, intscore): return mutations_table - - if __name__ == '__main__': app.run() diff --git a/requirements.txt b/requirements.txt index 54d8b25..3f9b19b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ Flask~=3.0.3 flask-restx~=1.3.0 marshmallow~=3.21.3 -pandas~=2.2.2 \ No newline at end of file +pandas~=2.2.2 +flask-cors~=4.0.1