Skip to content

Commit

Permalink
Merge pull request #110 from OutboundSpade/main
Browse files Browse the repository at this point in the history
Switch route-based CORS to app-wide CORS policy
  • Loading branch information
vanfossen committed Aug 16, 2023
2 parents 5d9784c + 13b12fb commit 4e4fa0a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json

from flask import Flask, request
from flask_cors import cross_origin
from flask_cors import CORS
from processing import (
generate_spectrum,
generate_background,
Expand All @@ -15,6 +15,7 @@
from processing_utils import param_check

app = Flask(__name__)
CORS(app)
try:
with open("version.txt","r") as f:
version = f.read()
Expand All @@ -23,14 +24,12 @@
print("no version file found")

@app.route("/", methods=["GET"])
@cross_origin()
def ftir() -> str:
if "VERSION" not in app.config:
app.config["VERSION"] = "0.0.0"
return "<h1 style='color:blue'>Raston Lab FTIR API%s</h1>" % (" - Version "+app.config["VERSION"])

@app.route("/spectrum", methods=["POST"])
@cross_origin(origins=['http://localhost:3000', 'https://ftir.rastonlab.org'])
def spectrum() -> dict[bool, list[float], list[float]]:
# put incoming JSON into a dictionary
params = json.loads(request.data)
Expand Down Expand Up @@ -69,7 +68,6 @@ def spectrum() -> dict[bool, list[float], list[float]]:


@app.route("/background", methods=["POST"])
@cross_origin(origins=['http://localhost:3000', 'https://ftir.rastonlab.org'])
def background() -> dict[bool, list[float], list[float]]:
# put incoming JSON into a dictionary
data = json.loads(request.data)
Expand Down Expand Up @@ -122,7 +120,6 @@ def background() -> dict[bool, list[float], list[float]]:


@app.route("/find_peaks", methods=["POST"])
@cross_origin(origins=['http://localhost:3000', 'https://ftir.rastonlab.org'])
def handle_peaks() -> dict[bool, dict[float, float], str]:
data = json.loads(request.data)

Expand Down

0 comments on commit 4e4fa0a

Please sign in to comment.