forked from Itope84/star-spotter-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/gmercyo/star-spotter-api
- Loading branch information
Showing
7 changed files
with
39 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.env | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,46 @@ | ||
from find_actor import find_actor_by_image, find_actor_profile, find_actor_id | ||
from flask import Flask, request, jsonify | ||
from flask_cors import CORS | ||
|
||
app = Flask(__name__) | ||
|
||
# TODO: Enable CORS for allowed origins to enable web support. | ||
# CORS(app, resources={r"/*": {"origins": "*"}}) | ||
|
||
|
||
@app.route("/status", methods=["GET"]) | ||
def get_status(): | ||
return jsonify({"message": "Hello world"}) | ||
|
||
|
||
@app.route("/search", methods=["GET"]) | ||
def search(): | ||
actor_name = request.args.get('name', default='') | ||
actor_id = find_actor_id(actor_name) | ||
if actor_id is not None: | ||
actor_profile = find_actor_profile(actor_id) | ||
return jsonify(actor_profile) | ||
else: | ||
return jsonify({"error": "Actor not found"}), 404 | ||
|
||
@app.route("/rekognise", methods =["POST"]) | ||
actor_name = request.args.get("name", default="") | ||
actor_id = find_actor_id(actor_name) | ||
if actor_id is not None: | ||
actor_profile = find_actor_profile(actor_id) | ||
return jsonify(actor_profile) | ||
else: | ||
return jsonify({"error": "Actor not found"}), 404 | ||
|
||
|
||
@app.route("/rekognise", methods=["POST"]) | ||
def rekognise(): | ||
if 'image' not in request.files: | ||
if "image" not in request.files: | ||
return jsonify({"error": "No file part"}), 400 | ||
|
||
file = request.files['image'] | ||
file = request.files["image"] | ||
|
||
if file and file.filename != '': | ||
if file and file.filename != "": | ||
actor_name = find_actor_by_image(file) | ||
if actor_name is not None: | ||
return jsonify({"name": actor_name}) | ||
else: | ||
return jsonify({"error": "Actor not found"}), 404 | ||
else: | ||
# If the user does not select a file, the browser submits an empty file without a filename. | ||
return jsonify({"error": "No selected file"}), 400 | ||
# If the user does not select a file, the browser submits an empty file without a filename. | ||
return jsonify({"error": "No selected file"}), 400 | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ boto3==1.34.7 | |
botocore==1.34.7 | ||
urllib3==1.26.18 | ||
zappa==0.58.0 | ||
Flask-Cors==4.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters