Spaces:
Running
Running
Create static/infographic_gen.html
Browse files- static/infographic_gen.html +140 -0
static/infographic_gen.html
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<title>Infographic Generator</title>
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<!-- Bootstrap CSS -->
|
8 |
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
9 |
+
<!-- Font Awesome CSS -->
|
10 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
|
11 |
+
<!-- Custom CSS -->
|
12 |
+
<style>
|
13 |
+
body {
|
14 |
+
background-color: #f0f2f5;
|
15 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
16 |
+
color: #333;
|
17 |
+
}
|
18 |
+
.header {
|
19 |
+
background: linear-gradient(135deg, #4a90e2, #9013fe);
|
20 |
+
color: white;
|
21 |
+
padding: 60px 0;
|
22 |
+
text-align: center;
|
23 |
+
}
|
24 |
+
.header h1 {
|
25 |
+
font-size: 3rem;
|
26 |
+
font-weight: bold;
|
27 |
+
}
|
28 |
+
.header p {
|
29 |
+
font-size: 1.2rem;
|
30 |
+
margin-top: 10px;
|
31 |
+
}
|
32 |
+
.main-content {
|
33 |
+
margin-top: -50px;
|
34 |
+
}
|
35 |
+
.card {
|
36 |
+
border-radius: 15px;
|
37 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
|
38 |
+
}
|
39 |
+
#generate-btn {
|
40 |
+
background: linear-gradient(135deg, #4a90e2, #9013fe);
|
41 |
+
border: none;
|
42 |
+
}
|
43 |
+
#generate-btn:hover {
|
44 |
+
background: linear-gradient(135deg, #3b78c4, #7d0fcf);
|
45 |
+
}
|
46 |
+
#download-btn {
|
47 |
+
background: #28a745;
|
48 |
+
border: none;
|
49 |
+
}
|
50 |
+
#download-btn:hover {
|
51 |
+
background: #218838;
|
52 |
+
}
|
53 |
+
#output-frame {
|
54 |
+
width: 100%;
|
55 |
+
height: 600px;
|
56 |
+
border: none;
|
57 |
+
border-radius: 15px;
|
58 |
+
}
|
59 |
+
</style>
|
60 |
+
</head>
|
61 |
+
<body>
|
62 |
+
<header class="header">
|
63 |
+
<div class="container">
|
64 |
+
<h1><i class="fas fa-chart-bar me-2"></i>Infographic Generator</h1>
|
65 |
+
<p><i class="fas fa-lightbulb me-2"></i>Provide a single sentence describing the infographic you want to generate.</p>
|
66 |
+
</div>
|
67 |
+
</header>
|
68 |
+
<div class="container main-content">
|
69 |
+
<div class="row">
|
70 |
+
<!-- Input Section -->
|
71 |
+
<div class="col-md-4 mb-4">
|
72 |
+
<div class="card p-4">
|
73 |
+
<h3 class="mb-3">
|
74 |
+
<i class="fas fa-pencil-alt me-2"></i>Describe Your Infographic
|
75 |
+
</h3>
|
76 |
+
<textarea id="description" class="form-control mb-3" rows="10" placeholder="E.g., 'An infographic showing the benefits of renewable energy'"></textarea>
|
77 |
+
<button id="generate-btn" class="btn btn-primary btn-lg w-100">
|
78 |
+
<i class="fas fa-magic me-2"></i>Generate Infographic
|
79 |
+
</button>
|
80 |
+
</div>
|
81 |
+
</div>
|
82 |
+
<!-- Output Section -->
|
83 |
+
<div class="col-md-8 mb-4">
|
84 |
+
<div class="card p-4">
|
85 |
+
<h3 class="mb-3">
|
86 |
+
<i class="fas fa-image me-2"></i>Generated Infographic
|
87 |
+
</h3>
|
88 |
+
<iframe id="output-frame"></iframe>
|
89 |
+
<button id="download-btn" class="btn btn-success btn-lg w-100 mt-3">
|
90 |
+
<i class="fas fa-download me-2"></i>Download as Image
|
91 |
+
</button>
|
92 |
+
</div>
|
93 |
+
</div>
|
94 |
+
</div>
|
95 |
+
</div>
|
96 |
+
|
97 |
+
<!-- Include Bootstrap JS and dependencies -->
|
98 |
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
99 |
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
100 |
+
<!-- Font Awesome -->
|
101 |
+
<script src="https://kit.fontawesome.com/yourkit.js" crossorigin="anonymous"></script>
|
102 |
+
<!-- html2canvas for screenshot functionality -->
|
103 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
|
104 |
+
<script>
|
105 |
+
$(document).ready(function() {
|
106 |
+
// Generate infographic
|
107 |
+
$('#generate-btn').click(function() {
|
108 |
+
var description = $('#description').val();
|
109 |
+
$.ajax({
|
110 |
+
url: '/generate',
|
111 |
+
type: 'POST',
|
112 |
+
contentType: 'application/json',
|
113 |
+
data: JSON.stringify({ description: description }),
|
114 |
+
success: function(response) {
|
115 |
+
$('#output-frame').contents().find('body').html(response.html);
|
116 |
+
},
|
117 |
+
error: function(xhr, status, error) {
|
118 |
+
$('#output-frame').contents().find('body').html('<div class="alert alert-danger">An error occurred: ' + error + '</div>');
|
119 |
+
}
|
120 |
+
});
|
121 |
+
});
|
122 |
+
|
123 |
+
// Download infographic as an image
|
124 |
+
$('#download-btn').click(function() {
|
125 |
+
const iframe = document.getElementById('output-frame');
|
126 |
+
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
|
127 |
+
|
128 |
+
html2canvas(iframeDocument.body).then(function(canvas) {
|
129 |
+
const link = document.createElement('a');
|
130 |
+
link.download = 'infographic.png';
|
131 |
+
link.href = canvas.toDataURL();
|
132 |
+
link.click();
|
133 |
+
}).catch(function(error) {
|
134 |
+
alert('An error occurred while capturing the infographic: ' + error);
|
135 |
+
});
|
136 |
+
});
|
137 |
+
});
|
138 |
+
</script>
|
139 |
+
</body>
|
140 |
+
</html>
|