Files changed (1) hide show
  1. index.html +76 -18
index.html CHANGED
@@ -1,19 +1,77 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>AI Storyboard - Final Test</title>
6
+ <style>
7
+ body { font-family: sans-serif; background: #111; color: white; padding: 40px; text-align: center; }
8
+ .box { background: #222; padding: 20px; border-radius: 10px; max-width: 600px; margin: auto; }
9
+ input, textarea { width: 100%; padding: 10px; margin-top: 10px; border-radius: 5px; border: none; }
10
+ button { background: #7c3aed; color: white; padding: 15px 30px; border: none; border-radius: 5px; cursor: pointer; margin-top: 20px; width: 100%; font-weight: bold; }
11
+ #output img { width: 100%; margin-top: 20px; border-radius: 10px; border: 2px solid #555; }
12
+ #status { margin-top: 15px; color: #fbbf24; }
13
+ </style>
14
+ </head>
15
+ <body>
16
+
17
+ <div class="box">
18
+ <h2>Storyboard Creator</h2>
19
+ <input type="password" id="token" placeholder="Paste your hf_... token here">
20
+ <textarea id="prompt" rows="4" placeholder="Describe the scene (e.g. A cat sitting on a throne, pixar style)"></textarea>
21
+ <button onclick="generateImage()">Generate Image</button>
22
+ <div id="status"></div>
23
+ <div id="output"></div>
24
+ </div>
25
+
26
+ <script>
27
+ async function generateImage() {
28
+ const token = document.getElementById('token').value.trim();
29
+ const prompt = document.getElementById('prompt').value.trim();
30
+ const status = document.getElementById('status');
31
+ const output = document.getElementById('output');
32
+
33
+ if (!token || !prompt) { alert("Please fill both fields!"); return; }
34
+
35
+ status.innerText = "Connecting to AI Model... (Please wait 20-30 seconds)";
36
+ output.innerHTML = "";
37
+
38
+ try {
39
+ const response = await fetch(
40
+ "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell",
41
+ {
42
+ headers: {
43
+ "Authorization": `Bearer ${token}`,
44
+ "Content-Type": "application/json"
45
+ },
46
+ method: "POST",
47
+ body: JSON.stringify({ inputs: prompt }),
48
+ }
49
+ );
50
+
51
+ if (response.status === 503) {
52
+ status.innerText = "Model is loading... Retrying in 5 seconds.";
53
+ setTimeout(generateImage, 5000);
54
+ return;
55
+ }
56
+
57
+ if (!response.ok) {
58
+ const errorData = await response.json();
59
+ throw new Error(errorData.error || "API Error");
60
+ }
61
+
62
+ const blob = await response.blob();
63
+ const imgUrl = URL.createObjectURL(blob);
64
+ output.innerHTML = `<img src="${imgUrl}">`;
65
+ status.innerText = "Image Generated Successfully!";
66
+
67
+ } catch (error) {
68
+ status.innerText = "Error: " + error.message;
69
+ console.error(error);
70
+ }
71
+ }
72
+ </script>
73
+
74
+ </body>
75
  </html>
76
+
77
+