Public
Back
Version 5
11/2/2024
/** @jsxImportSource https://esm.sh/react */
import React, { useEffect, useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
import ReactMarkdown from "https://esm.sh/react-markdown";
import { Prism as SyntaxHighlighter } from "https://esm.sh/react-syntax-highlighter";
import { vscDarkPlus } from "https://esm.sh/react-syntax-highlighter/dist/esm/styles/prism";
function App() {
const [input, setInput] = useState("");
const [response, setResponse] = useState("");
const [loading, setLoading] = useState(false);
const [language, setLanguage] = useState("typescript");
useEffect(() => {
const savedLanguage = localStorage.getItem("codeLanguage");
if (savedLanguage) {
setLanguage(savedLanguage);
}
}, []);
const handleLanguageChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
const newLanguage = e.target.value;
setLanguage(newLanguage);
localStorage.setItem("codeLanguage", newLanguage);
};
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setLoading(true);
try {
const res = await fetch("/generate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ prompt: input, language }),
});
const data = await res.json();
alfongj-crossmintsolanatxgenerator.web.val.run
Updated: November 2, 2024