Skip to content

Commit

Permalink
build image proxy endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
gmercyo committed Jan 18, 2024
1 parent 4dabe3a commit 52e7003
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
from find_actor import find_actor_by_image, find_actor_profile, find_actor_id
from flask import Flask, request, jsonify
from flask import Flask, request, jsonify, Response
from flask_cors import CORS
import requests

app = Flask(__name__)

# Allow cross-origin request from all domains
CORS(app, resources={r"/*": {"origins": ["https://app.star-spotter.com"]}})


@app.route('/img_proxy')
def img_proxy():
image_url = request.args.get('url')
if not image_url:
return "No URL provided", 400

try:
response = requests.get(image_url)
return Response(response.content, content_type=response.headers['Content-Type'])
except requests.RequestException as e:
return str(e), 500

@app.route("/status", methods=["GET"])
def get_status():
return jsonify({"message": "Hello world"})
Expand Down

0 comments on commit 52e7003

Please sign in to comment.