Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gmercyo committed Jan 11, 2024
2 parents 536aa8a + 0e89196 commit 92aaa41
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 20 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ jobs:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
RAPID_API_KEY: ${{ secrets.RAPID_API_KEY }}
run: |
pipenv run zappa update dev
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.env
__pycache__
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Scene Seeker API
# Star Spotter API

This simple Python API for the "Scene Seeker" app provides a `/status` endpoint that returns a "Hello world" message.
Python API that allows you to take a picture of an actor in a movie scene and get their name as well as other movies they've been in. This API powers the Star Spotter App.

## Prerequisites

Expand All @@ -16,7 +16,7 @@ To install Scene Seeker API, follow these steps:
1. Clone the repository to your local machine:

```bash
git clone https://github.com/Itope84/star-spotter-api.git
git clone https://github.com/gmerco/star-spotter-api.git
```

1. Navigate to the cloned repository:
Expand Down
Binary file removed __pycache__/find_actor.cpython-310.pyc
Binary file not shown.
38 changes: 22 additions & 16 deletions app.py
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)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 11 additions & 1 deletion zappa_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
"runtime": "python3.10",
"s3_bucket": "star-spotter",
"environment_variables": {
"RAPID_API_KEY": "697613e8f9mshebae93db16f4687p191ee3jsn1740d0122ff4"
"RAPID_API_KEY": "$RAPID_API_KEY"
}
},
"prod": {
"app_function": "app.app",
"aws_region": "us-east-2",
"project_name": "star-spotter-api",
"runtime": "python3.10",
"s3_bucket": "star-spotter-prod",
"environment_variables": {
"RAPID_API_KEY": "$RAPID_API_KEY"
}
}
}

0 comments on commit 92aaa41

Please sign in to comment.