import { useState } from 'react'; export default function Home() { const [htmlContent, setHtmlContent] = useState(''); const [loading, setLoading] = useState(false); const [result, setResult] = useState<{ url: string } | null>(null); const [error, setError] = useState(null); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(null); setResult(null); try { const response = await fetch('http://localhost:8000/api/html/generate', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ html_content: htmlContent }), }); if (!response.ok) { throw new Error('生成 HTML 文件失败'); } const data = await response.json(); setResult({ url: data.url }); } catch (err) { setError('生成 HTML 文件失败,请稍后重试'); console.error(err); } finally { setLoading(false); } }; return (

HTML 文件生成器