Spaces:
Running
Running
Create templates/index.html
Browse files- templates/index.html +66 -0
templates/index.html
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>AI Text-to-Video Generator</title>
|
| 7 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
|
| 8 |
+
</head>
|
| 9 |
+
<body class="bg-light">
|
| 10 |
+
|
| 11 |
+
<div class="container">
|
| 12 |
+
<h1 class="text-center mt-5">AI Text-to-Video Generator</h1>
|
| 13 |
+
|
| 14 |
+
<div class="card mt-4 p-4 shadow mx-auto" style="max-width: 600px;">
|
| 15 |
+
<label for="prompt" class="form-label">Enter Your Prompt:</label>
|
| 16 |
+
<input type="text" id="prompt" class="form-control" placeholder="E.g., Astronaut in a jungle...">
|
| 17 |
+
|
| 18 |
+
<button id="generateBtn" class="btn btn-primary mt-3">Generate Video</button>
|
| 19 |
+
|
| 20 |
+
<div id="loading" class="text-center mt-3" style="display: none;">
|
| 21 |
+
<div class="spinner-border text-primary" role="status"></div>
|
| 22 |
+
<p>Generating video...</p>
|
| 23 |
+
</div>
|
| 24 |
+
|
| 25 |
+
<div id="video-container" class="mt-4 text-center" style="display: none;">
|
| 26 |
+
<h3>Generated Video:</h3>
|
| 27 |
+
<video id="generatedVideo" controls class="w-100"></video>
|
| 28 |
+
</div>
|
| 29 |
+
</div>
|
| 30 |
+
</div>
|
| 31 |
+
|
| 32 |
+
<script>
|
| 33 |
+
document.getElementById("generateBtn").addEventListener("click", async function() {
|
| 34 |
+
const prompt = document.getElementById("prompt").value;
|
| 35 |
+
if (!prompt) {
|
| 36 |
+
alert("Please enter a prompt.");
|
| 37 |
+
return;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
document.getElementById("loading").style.display = "block";
|
| 41 |
+
document.getElementById("video-container").style.display = "none";
|
| 42 |
+
|
| 43 |
+
try {
|
| 44 |
+
const response = await fetch("/generate", {
|
| 45 |
+
method: "POST",
|
| 46 |
+
headers: { "Content-Type": "application/json" },
|
| 47 |
+
body: JSON.stringify({ prompt })
|
| 48 |
+
});
|
| 49 |
+
|
| 50 |
+
const data = await response.json();
|
| 51 |
+
if (data.error) {
|
| 52 |
+
alert("Error: " + data.error);
|
| 53 |
+
} else {
|
| 54 |
+
document.getElementById("generatedVideo").src = data.video_url;
|
| 55 |
+
document.getElementById("video-container").style.display = "block";
|
| 56 |
+
}
|
| 57 |
+
} catch (error) {
|
| 58 |
+
alert("Error generating video!");
|
| 59 |
+
} finally {
|
| 60 |
+
document.getElementById("loading").style.display = "none";
|
| 61 |
+
}
|
| 62 |
+
});
|
| 63 |
+
</script>
|
| 64 |
+
|
| 65 |
+
</body>
|
| 66 |
+
</html>
|