duqing2026 commited on
Commit
6a594de
·
1 Parent(s): 9941aa6

Optimize: add default data, download feature, and fix deployment config

Browse files
Files changed (4) hide show
  1. .gitignore +2 -0
  2. Dockerfile +5 -5
  3. requirements.txt +2 -0
  4. templates/index.html +42 -27
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ __pycache__/
2
+ *.pyc
Dockerfile CHANGED
@@ -1,11 +1,11 @@
1
  FROM python:3.9-slim
2
 
3
- WORKDIR /app
4
 
5
- COPY . /app
6
 
7
- RUN pip install flask
8
 
9
- EXPOSE 7860
10
 
11
- CMD ["python", "app.py"]
 
1
  FROM python:3.9-slim
2
 
3
+ WORKDIR /code
4
 
5
+ COPY ./requirements.txt /code/requirements.txt
6
 
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
 
9
+ COPY . .
10
 
11
+ CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ Flask==3.0.0
2
+ gunicorn==21.2.0
templates/index.html CHANGED
@@ -303,48 +303,50 @@ createApp({
303
  // Form Data States
304
  const forms = reactive({
305
  article: {
306
- headline: '',
307
- image: '',
308
- authorName: '',
309
- publisherName: '',
310
- datePublished: '',
311
- dateModified: '',
312
- description: ''
313
  },
314
  product: {
315
- name: '',
316
- image: '',
317
- description: '',
318
- brand: '',
319
- sku: '',
320
- price: '',
321
  priceCurrency: 'CNY',
322
  availability: 'InStock',
323
- ratingValue: '',
324
- reviewCount: ''
325
  },
326
  faq: {
327
  questions: [
328
- { question: '', answer: '' }
 
329
  ]
330
  },
331
  breadcrumb: {
332
  items: [
333
  { name: '首页', item: 'https://example.com' },
334
- { name: '分类', item: 'https://example.com/category' }
 
335
  ]
336
  },
337
  event: {
338
- name: '',
339
- startDate: '',
340
- endDate: '',
341
- locationName: '',
342
- address: '',
343
- image: '',
344
- description: '',
345
- price: '',
346
- priceCurrency: 'CNY',
347
- url: ''
348
  }
349
  });
350
 
@@ -500,6 +502,18 @@ createApp({
500
  setTimeout(() => copyBtnText.value = '复制', 2000);
501
  });
502
  };
 
 
 
 
 
 
 
 
 
 
 
 
503
 
504
  const resetForm = () => {
505
  // Simple reload or reset state manually. Reload is easiest for MVP.
@@ -521,6 +535,7 @@ createApp({
521
  removeBreadcrumbItem,
522
  copyCode,
523
  copyBtnText,
 
524
  resetForm
525
  };
526
  }
 
303
  // Form Data States
304
  const forms = reactive({
305
  article: {
306
+ headline: '2024年人工智能发展趋势报告',
307
+ image: 'https://images.unsplash.com/photo-1677442136019-21780ecad995',
308
+ authorName: '科技观察者',
309
+ publisherName: '未来科技网',
310
+ datePublished: new Date().toISOString().split('T')[0],
311
+ dateModified: new Date().toISOString().split('T')[0],
312
+ description: '深入探讨2024年人工智能技术的最新突破与行业应用前景...'
313
  },
314
  product: {
315
+ name: '极客机械键盘 Pro',
316
+ image: 'https://images.unsplash.com/photo-1587829741301-dc798b91a05c',
317
+ description: '专为程序员设计的机械键盘,采用顶级轴体,提供极致打字体验。',
318
+ brand: 'GeekGear',
319
+ sku: 'GG-MK-PRO-001',
320
+ price: '899',
321
  priceCurrency: 'CNY',
322
  availability: 'InStock',
323
+ ratingValue: '4.8',
324
+ reviewCount: '128'
325
  },
326
  faq: {
327
  questions: [
328
+ { question: '这款键盘支持热插拔吗?', answer: '支持,您可以自由更换市面上绝大多数三脚/五脚轴体。' },
329
+ { question: '保修期是多久?', answer: '我们提供2年的官方质保服务。' }
330
  ]
331
  },
332
  breadcrumb: {
333
  items: [
334
  { name: '首页', item: 'https://example.com' },
335
+ { name: '数码产品', item: 'https://example.com/digital' },
336
+ { name: '机械键盘', item: 'https://example.com/digital/keyboards' }
337
  ]
338
  },
339
  event: {
340
+ name: '2024 全球开发者大会',
341
+ startDate: '2024-06-15T09:00',
342
+ endDate: '2024-06-17T18:00',
343
+ locationName: '硅谷会议中心',
344
+ address: '123 Tech Way, San Jose, CA',
345
+ image: 'https://images.unsplash.com/photo-1540575467063-178a50c2df87',
346
+ description: '汇聚全球顶尖开发者的年度盛会,分享最新技术趋势。',
347
+ price: '299',
348
+ priceCurrency: 'USD',
349
+ url: 'https://example.com/events/2024-conf'
350
  }
351
  });
352
 
 
502
  setTimeout(() => copyBtnText.value = '复制', 2000);
503
  });
504
  };
505
+
506
+ const downloadJson = () => {
507
+ const blob = new Blob([generatedJson.value], { type: 'application/ld+json' });
508
+ const url = URL.createObjectURL(blob);
509
+ const a = document.createElement('a');
510
+ a.href = url;
511
+ a.download = `${currentType.value.toLowerCase()}-schema.json`;
512
+ document.body.appendChild(a);
513
+ a.click();
514
+ document.body.removeChild(a);
515
+ URL.revokeObjectURL(url);
516
+ };
517
 
518
  const resetForm = () => {
519
  // Simple reload or reset state manually. Reload is easiest for MVP.
 
535
  removeBreadcrumbItem,
536
  copyCode,
537
  copyBtnText,
538
+ downloadJson,
539
  resetForm
540
  };
541
  }