Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Web_app/movie_reviews.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Name,Movie,Review

187 changes: 187 additions & 0 deletions Web_app/pages/API_Documentation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
import streamlit as st

st.subheader(" API Documentation", divider="rainbow")
# Custom CSS for styling
st.markdown(
"""
<style>
body {
color: #333;
font-family: 'Arial', sans-serif;
}
.faq-title {
color: #FF5733;
font-size: 24px;
margin-top: 20px;
font-weight: bold;
}
.code-snippet {
font-family: 'Courier New', monospace;
background-color: #f0f0f0;
padding: 10px;
border-radius: 5px;
color: black;
}
</style>
""",
unsafe_allow_html=True,
)

# API Product Overview
st.subheader("🔍 API Product Overview")
st.write(
"The IMDb API on AWS Data Exchange offers a GraphQL-based approach, enabling efficient data access for movie and TV series metadata, "
"ratings, and box office data in real-time. It provides a streamlined JSON structure and single URL access for reduced API calls."
)

# Benefits
st.subheader("🌟 Key Benefits")
st.markdown(
"""
- **One Call, All Data**: Access all data via a single URL.
- **Flexible Queries**: Request only the specific fields you need, minimizing data over-fetching.
- **Real-time Updates**: Receive IMDb’s latest data without delay.
- **Multiple Entities**: Query multiple titles/names simultaneously.
""",
unsafe_allow_html=True,
)

# Getting Access to the API
st.subheader("🔑 Getting Access to the API")
st.write(
"To access the IMDb API, you need an AWS account and AWS Access Keys. Follow these steps to set up your access."
)
st.markdown(
"""
1. **Create an AWS Account**: The IMDb API is available through AWS Data Exchange.
2. **Obtain AWS Access Keys**: Generate your keys for API authentication.
3. **Enable Cost Explorer (Optional)**: View your usage and cost in AWS Cost Explorer.
""",
unsafe_allow_html=True,
)

# Authentication and API Key
st.subheader("🔒 Authentication and API Key")
st.write(
"For API calls, the `x-api-key` header must include your API Key. Authenticate requests using AWS credentials in one of the following ways."
)

# Code Snippet for AWS CLI
st.markdown(
"""
**Example API Call (AWS CLI)**:
""",
unsafe_allow_html=True,
)
st.code(
"""
aws dataexchange send-api-asset \\
--data-set-id <Dataset ID> \\
--revision-id <Revision ID> \\
--asset-id <Asset ID> \\
--request-headers "{ 'x-api-key': '<Your API Key>'}" \\
--region us-east-1 \\
--body "{ 'query': '{ title(id: \"tt0120338\") { ratingsSummary { aggregateRating voteCount } } }' }"
""",
language="bash",
)

# Sample GraphQL Query
st.subheader("💻 Sample Query")
st.write("Here’s a sample GraphQL query to retrieve the IMDb rating for *Titanic*:")

st.markdown(
"""
<div class="code-snippet">
{
title(id: "tt0120338") {
ratingsSummary {
aggregateRating
voteCount
}
}
}
</div>
""",
unsafe_allow_html=True,
)

# Response Example
st.subheader("📊 Sample API Response")
st.write('{\n "data": {\n "title": {\n "ratingsSummary": {')
st.write(' "aggregateRating": 7.9,\n "voteCount": 1133828')
st.write(" }\n }\n }\n}")

# Additional Code Snippets
st.subheader("📜 Additional Code Snippets")

# Code Snippet for Postman Request
st.write("**Making Requests via Postman**")
st.markdown(
"""
1. **Set Method**: Use `POST` method.
2. **Request URL**: `https://api-fulfill.dataexchange.us-east-1.amazonaws.com/v1`
3. **Headers**:
- `Content-Type`: `application/json`
- `x-api-key`: `<Your API Key>`
4. **Body (GraphQL Query)**:
```graphql
{
title(id: "tt0120338") {
ratingsSummary {
aggregateRating
voteCount
}
}
}
```
""",
unsafe_allow_html=True,
)

# Code Snippet for Python API Call
st.write("**Python Code to Make an API Call**")
st.code(
"""
import requests

url = "https://api-fulfill.dataexchange.us-east-1.amazonaws.com/v1"
headers = {
"x-api-key": "<Your API Key>",
"Content-Type": "application/json"
}
query = '''
{
title(id: "tt0120338") {
ratingsSummary {
aggregateRating
voteCount
}
}
}
'''
response = requests.post(url, headers=headers, data=query)
print(response.json())
""",
language="python",
)

# Example Use Cases
st.subheader("📄 Example Use Cases")
st.markdown(
"""
1. **Retrieve Ratings**: Query title ratings and vote counts.
2. **Box Office Data**: Access box office gross data.
3. **Cast and Crew**: Fetch top cast or crew details for movies and shows.
4. **Search Functionality**: Use keywords to find specific titles or names.
5. **Real-time Data Access**: Display data updates as they become available on IMDb.
""",
unsafe_allow_html=True,
)

# Footer
st.markdown("---")
st.markdown(
"<small>For further assistance, contact support at [email protected]</small>",
unsafe_allow_html=True,
)
131 changes: 131 additions & 0 deletions Web_app/pages/ReviewSubmission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import streamlit as st
import os
import pandas as pd

# Set the path for storing the reviews
reviews_file = "movie_reviews.csv"

# Initialize the reviews file if it doesn't exist
if not os.path.exists(reviews_file):
df = pd.DataFrame(columns=["Name", "Movie", "Review"])
df.to_csv(reviews_file, index=False)

# Read the existing reviews from the file
df = pd.read_csv(reviews_file)

# Initialize session state for showing the review form
if "show_review_form" not in st.session_state:
st.session_state.show_review_form = False

st.title("🎬 Submit Your Movie Review")

st.markdown(
"<div style='height: 5px; background: linear-gradient(to right, #FF5733, #FFC300, #DAF7A6, #33FF57, #3380FF);'></div>",
unsafe_allow_html=True,
)

# Updated Custom CSS for Reddit-style reviews with dynamic sizing
st.markdown(
"""
<style>
.review-box {
background-color: #f8f9fa;
padding: 12px;
border-radius: 4px;
margin-bottom: 16px;
border: 1px solid #e3e6e8;
width: auto;
max-width: 100%;
height: auto;
overflow-wrap: break-word;
word-wrap: break-word;
hyphens: auto;
}
.review-header {
color: #1a1a1b;
font-size: 12px;
font-weight: 400;
line-height: 16px;
display: flex;
align-items: center;
margin-bottom: 8px;
flex-wrap: wrap;
}
.review-author {
color: #1c1c1c;
font-weight: 700; /* Changed to bold */
margin-right: 4px;
text-transform: capitalize;
}
.review-movie {
color: red;
text-transform: capitalize;
}
.review-content {
font-size: 14px;
line-height: 21px;
font-weight: 400;
color: #1a1a1b;
white-space: pre-wrap; /* Preserves line breaks and spaces */
}
.toggle-button {
cursor: pointer;
color: #0079D3;
}
</style>
""",
unsafe_allow_html=True,
)

# Toggle for review form visibility
show_review_form = st.checkbox(
"➕ Submit Review", value=st.session_state.show_review_form, key="review_checkbox"
)

# Update session state based on checkbox
st.session_state.show_review_form = show_review_form

# Form for submitting reviews
if st.session_state.show_review_form:
with st.form(key="review_form"):
name = st.text_input("Your Name")
movie_name = st.text_input("Movie Name")
review = st.text_area("Your Review", height=80)
submit_button = st.form_submit_button(label="Submit Review")

if submit_button:
if name and movie_name and review:
new_review = pd.DataFrame(
{
"Name": [name],
"Movie": [movie_name],
"Review": [review],
}
)
df = pd.concat([df, new_review], ignore_index=True)
df.to_csv(reviews_file, index=False)
st.success("Thank you for your review!")
st.session_state.show_review_form = False
st.rerun()
else:
st.error("Please fill in all fields before submitting.")

# Display the reviews in a Reddit-style comment format
st.subheader("📜 Reviews")

if not df.empty:
for index, row in df.iterrows():
st.markdown(
f"""
<div class="review-box">
<div class="review-header">
<span class="review-author">{row['Name']}</span>
<span class="review-movie">{row['Movie']}</span>
</div>
<div class="review-content">{row['Review']}</div>
</div>
""",
unsafe_allow_html=True,
)
else:
st.write("No reviews yet. Be the first to leave one!")
Loading