Your full working Movie Search App is ready in the canvas.
Before using it:
- Replace
YOUR_API_KEYwith your OMDB API key - Get it from: http://www.omdbapi.com/apikey.aspx
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Movie Search App</title>
<style>
body {
font-family: Arial, sans-serif;
background: #0f172a;
color: white;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
text-align: center;
width: 350px;
}
h1 {
margin-bottom: 20px;
}
input {
width: 70%;
padding: 10px;
border-radius: 8px;
border: none;
outline: none;
}
button {
padding: 10px 15px;
border: none;
border-radius: 8px;
cursor: pointer;
background: #22c55e;
color: white;
}
.card {
margin-top: 20px;
background: #1e293b;
padding: 15px;
border-radius: 12px;
}
img {
width: 100%;
border-radius: 10px;
}
.error {
color: red;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>🎬 Movie Search</h1>
<input type="text" id="movieInput" placeholder="Enter movie name">
<button onclick="searchMovie()">Search</button>
<div id="result"></div>
</div>
<script>
const API_KEY = "YOUR_API_KEY"; // Replace with your OMDB API key
async function searchMovie() {
const movieName = document.getElementById("movieInput").value;
const resultDiv = document.getElementById("result");
if (movieName === "") {
resultDiv.innerHTML = "<p class='error'>Please enter a movie name</p>";
return;
}
resultDiv.innerHTML = "Loading...";
try {
const response = await fetch(`https://www.omdbapi.com/?apikey=${API_KEY}&t=${movieName}`);
const data = await response.json();
if (data.Response === "False") {
resultDiv.innerHTML = `<p class='error'>Movie not found</p>`;
return;
}
resultDiv.innerHTML = `
<div class="card">
<img src="${data.Poster}" alt="Poster">
<h2>${data.Title}</h2>
<p>⭐ Rating: ${data.imdbRating}</p>
<p>📅 Release: ${data.Released}</p>
</div>
`;
} catch (error) {
resultDiv.innerHTML = `<p class='error'>Something went wrong</p>`;
}
}
</script>
</body>
</html>






