colivafr commited on
Commit
e40d70e
·
verified ·
1 Parent(s): 9a13588

it seems there is nothing sent to webhook - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +260 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Test
3
- emoji: 🏆
4
- colorFrom: red
5
- colorTo: indigo
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: test
3
+ emoji: 🐳
4
+ colorFrom: green
5
+ colorTo: gray
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,260 @@
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
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>DropzoneJS with Webhook Response</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://unpkg.com/dropzone@5/dist/min/dropzone.min.css" type="text/css" />
9
+ <style>
10
+ .dropzone {
11
+ border: 2px dashed #4b5563;
12
+ border-radius: 0.5rem;
13
+ background: #f9fafb;
14
+ min-height: 150px;
15
+ padding: 20px;
16
+ }
17
+ .dropzone .dz-message {
18
+ margin: 3em 0;
19
+ color: #6b7280;
20
+ font-weight: 500;
21
+ }
22
+ .dropzone .dz-preview .dz-error-message {
23
+ background: #ef4444;
24
+ border-radius: 0.25rem;
25
+ }
26
+ .response-container {
27
+ transition: all 0.3s ease;
28
+ }
29
+ .spinner {
30
+ animation: spin 1s linear infinite;
31
+ }
32
+ @keyframes spin {
33
+ from { transform: rotate(0deg); }
34
+ to { transform: rotate(360deg); }
35
+ }
36
+ </style>
37
+ </head>
38
+ <body class="bg-gray-50 min-h-screen">
39
+ <div class="container mx-auto px-4 py-8 max-w-4xl">
40
+ <div class="text-center mb-8">
41
+ <h1 class="text-3xl font-bold text-gray-800 mb-2">File Upload with Webhook</h1>
42
+ <p class="text-gray-600">Upload files and see the API response in real-time</p>
43
+ </div>
44
+
45
+ <div class="bg-white rounded-xl shadow-md p-6 mb-8">
46
+ <form action="/upload" class="dropzone" id="fileDropzone">
47
+ <div class="dz-message" data-dz-message>
48
+ <div class="flex flex-col items-center justify-center">
49
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 text-gray-400 mb-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
50
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" />
51
+ </svg>
52
+ <span class="text-lg">Drop files here or click to upload</span>
53
+ <span class="text-sm text-gray-500 mt-1">Max file size: 10MB</span>
54
+ </div>
55
+ </div>
56
+ </form>
57
+ <div class="mt-4 flex justify-center">
58
+ <button id="submit-to-webhook" class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg transition-colors">
59
+ Submit to Webhook
60
+ </button>
61
+ </div>
62
+ </div>
63
+
64
+ <div id="response-section" class="bg-white rounded-xl shadow-md p-6 hidden">
65
+ <div class="flex items-center justify-between mb-4">
66
+ <h2 class="text-xl font-semibold text-gray-800">API Response</h2>
67
+ <button id="clear-response" class="text-gray-500 hover:text-gray-700">
68
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
69
+ <path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" />
70
+ </svg>
71
+ </button>
72
+ </div>
73
+ <div id="loading-indicator" class="hidden flex items-center justify-center py-8">
74
+ <svg class="animate-spin -ml-1 mr-3 h-8 w-8 text-blue-500 spinner" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
75
+ <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
76
+ <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
77
+ </svg>
78
+ <span class="text-gray-700">Processing your file...</span>
79
+ </div>
80
+ <pre id="api-response" class="bg-gray-50 p-4 rounded-lg overflow-x-auto text-sm text-gray-800 hidden"></pre>
81
+ <div id="error-message" class="hidden bg-red-50 border-l-4 border-red-500 p-4">
82
+ <div class="flex">
83
+ <div class="flex-shrink-0">
84
+ <svg class="h-5 w-5 text-red-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
85
+ <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
86
+ </svg>
87
+ </div>
88
+ <div class="ml-3">
89
+ <h3 class="text-sm font-medium text-red-800" id="error-title">Error</h3>
90
+ <div class="mt-2 text-sm text-red-700" id="error-content">
91
+ <p>There was an error processing your request.</p>
92
+ </div>
93
+ </div>
94
+ </div>
95
+ </div>
96
+ </div>
97
+ </div>
98
+
99
+ <script src="https://unpkg.com/dropzone@5/dist/min/dropzone.min.js"></script>
100
+ <script>
101
+ document.addEventListener('DOMContentLoaded', function() {
102
+ // Initialize Dropzone
103
+ Dropzone.autoDiscover = false;
104
+
105
+ const responseSection = document.getElementById('response-section');
106
+ const apiResponse = document.getElementById('api-response');
107
+ const loadingIndicator = document.getElementById('loading-indicator');
108
+ const errorMessage = document.getElementById('error-message');
109
+ const clearResponseBtn = document.getElementById('clear-response');
110
+
111
+ const dropzone = new Dropzone('#fileDropzone', {
112
+ url: 'https://n8n.flowbotix.com/webhook/test-webhook',
113
+ paramName: "file",
114
+ maxFilesize: 10, // MB
115
+ acceptedFiles: 'image/*,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt',
116
+ addRemoveLinks: true,
117
+ autoProcessQueue: true,
118
+ parallelUploads: 3,
119
+ dictDefaultMessage: "Drop files here or click to upload",
120
+ dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
121
+ dictFileTooBig: "File is too big ({{filesize}}MB). Max filesize: {{maxFilesize}}MB.",
122
+ dictInvalidFileType: "You can't upload files of this type.",
123
+ dictResponseError: "Server responded with {{statusCode}} code.",
124
+ dictCancelUpload: "Cancel upload",
125
+ dictUploadCanceled: "Upload canceled.",
126
+ dictRemoveFile: "Remove file",
127
+ dictMaxFilesExceeded: "You can't upload any more files.",
128
+ headers: {
129
+ 'Accept': 'application/json'
130
+ },
131
+ init: function() {
132
+ this.on('sending', function(file, xhr, formData) {
133
+ // Show loading state
134
+ responseSection.classList.remove('hidden');
135
+ loadingIndicator.classList.remove('hidden');
136
+ apiResponse.classList.add('hidden');
137
+ errorMessage.classList.add('hidden');
138
+
139
+ // Create object URL for the file and store it on the file object
140
+ file.objectUrl = URL.createObjectURL(file);
141
+
142
+ // Add file URL and metadata to the request
143
+ formData.append('timestamp', Date.now());
144
+ formData.append('client', 'dropzone-webhook-app');
145
+ formData.append('file_url', file.objectUrl);
146
+ formData.append('file_name', file.name);
147
+ formData.append('file_size', file.size);
148
+ formData.append('file_type', file.type);
149
+ });
150
+
151
+ this.on('success', function(file, response) {
152
+ loadingIndicator.classList.add('hidden');
153
+ apiResponse.classList.remove('hidden');
154
+ errorMessage.classList.add('hidden');
155
+
156
+ // Format and display the response
157
+ apiResponse.textContent = JSON.stringify(response, null, 2);
158
+
159
+ // Send complete file info to webhook
160
+ const fileInfo = {
161
+ event: 'file_upload_success',
162
+ timestamp: new Date().toISOString(),
163
+ file: {
164
+ name: file.name,
165
+ size: file.size,
166
+ type: file.type,
167
+ lastModified: file.lastModified,
168
+ uploadDate: new Date().toISOString(),
169
+ status: file.status,
170
+ objectUrl: file.objectUrl,
171
+ previewElement: file.previewElement ? true : false
172
+ },
173
+ uploadResponse: response,
174
+ metadata: {
175
+ client: 'dropzone-webhook-app',
176
+ processingTime: Date.now() - file.upload.processingStarted
177
+ }
178
+ };
179
+
180
+ fetch('https://n8n.flowbotix.com/webhook/test-webhook', {
181
+ method: 'POST',
182
+ headers: {
183
+ 'Content-Type': 'application/json',
184
+ },
185
+ body: JSON.stringify(fileInfo)
186
+ })
187
+ .then(() => {
188
+ console.log('Webhook notification sent successfully');
189
+ })
190
+ .catch(error => {
191
+ console.error('Error sending to webhook:', error);
192
+ });
193
+
194
+ // Clean up object URL and remove file preview
195
+ URL.revokeObjectURL(file.objectUrl);
196
+ this.removeFile(file);
197
+ });
198
+
199
+ this.on('error', function(file, errorMessageText, xhr) {
200
+ loadingIndicator.classList.add('hidden');
201
+ apiResponse.classList.add('hidden');
202
+ errorMessage.classList.remove('hidden');
203
+
204
+ let errorContent = '';
205
+ if (xhr) {
206
+ errorContent = `Status: ${xhr.status}\n`;
207
+ try {
208
+ const response = JSON.parse(xhr.responseText);
209
+ errorContent += `Message: ${response.message || xhr.responseText}`;
210
+ } catch (e) {
211
+ errorContent += `Response: ${xhr.responseText}`;
212
+ }
213
+ } else {
214
+ errorContent = errorMessageText;
215
+ }
216
+
217
+ document.getElementById('error-content').textContent = errorContent;
218
+ });
219
+
220
+ this.on('complete', function(file) {
221
+ if (!file.accepted) {
222
+ this.removeFile(file);
223
+ }
224
+ });
225
+ }
226
+ });
227
+
228
+ // Clear response button
229
+ clearResponseBtn.addEventListener('click', function() {
230
+ apiResponse.textContent = '';
231
+ responseSection.classList.add('hidden');
232
+ });
233
+
234
+ // Submit to webhook button
235
+ document.getElementById('submit-to-webhook').addEventListener('click', function() {
236
+ const payload = {
237
+ name: "hello"
238
+ };
239
+
240
+ fetch('https://n8n.flowbotix.com/webhook/test-webhook', {
241
+ method: 'POST',
242
+ headers: {
243
+ 'Content-Type': 'application/json',
244
+ },
245
+ body: JSON.stringify(payload)
246
+ })
247
+ .then(response => response.json())
248
+ .then(data => {
249
+ alert('Webhook called successfully!');
250
+ console.log('Webhook response:', data);
251
+ })
252
+ .catch(error => {
253
+ console.error('Error calling webhook:', error);
254
+ alert('Error calling webhook');
255
+ });
256
+ });
257
+ });
258
+ </script>
259
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=colivafr/test" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
260
+ </html>