hologramicon commited on
Commit
5bda975
·
verified ·
1 Parent(s): 05d33e9

Delete client

Browse files
client/index.html DELETED
@@ -1 +0,0 @@
1
- <!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>HF React App</title></head><body><div id="root"></div><script type="module" src="/src/main.tsx"></script></body></html>
 
 
client/package.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "name":"client",
3
- "private":true,
4
- "version":"0.0.0",
5
- "type":"module",
6
- "scripts":{
7
- "dev":"vite",
8
- "build":"vite build",
9
- "preview":"vite preview"
10
- },
11
- "dependencies":{
12
- "react":"18.2.0",
13
- "react-dom":"18.2.0"
14
- },
15
- "devDependencies":{
16
- "typescript":"5.5.0",
17
- "vite":"5.0.0",
18
- "@types/react":"18.2.28",
19
- "@types/react-dom":"18.2.11",
20
- "@vitejs/plugin-react":"^4.2.1"
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
client/src/App.tsx DELETED
@@ -1,3 +0,0 @@
1
- import React from 'react'
2
- import Home from './pages/Home'
3
- export default function App(){ return <Home/> }
 
 
 
 
client/src/api/hfClient.ts DELETED
@@ -1,7 +0,0 @@
1
- const API_BASE=import.meta.env.VITE_API_BASE||'http://localhost:4000'
2
- export async function generateText(prompt){
3
- const r=await fetch(API_BASE+'/api/generate-text',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({prompt})})
4
- if(!r.ok) throw new Error(r.status+' '+r.statusText)
5
- const j=await r.json()
6
- return j.output??JSON.stringify(j)
7
- }
 
 
 
 
 
 
 
 
client/src/main.tsx DELETED
@@ -1,4 +0,0 @@
1
- import React from 'react'
2
- import { createRoot } from 'react-dom/client'
3
- import App from './App'
4
- createRoot(document.getElementById('root')!).render(<React.StrictMode><App/></React.StrictMode>)
 
 
 
 
 
client/src/pages/Home.tsx DELETED
@@ -1,16 +0,0 @@
1
- import React,{useState} from 'react'
2
- import { generateText } from '../api/hfClient'
3
- export default function Home(){
4
- const [prompt,setPrompt]=useState('')
5
- const [result,setResult]=useState(null)
6
- const [loading,setLoading]=useState(false)
7
- async function onSubmit(e){
8
- e.preventDefault()
9
- setLoading(true)
10
- setResult(null)
11
- try{ setResult(await generateText(prompt)) }
12
- catch(err){ setResult('Error:'+String(err)) }
13
- finally{ setLoading(false) }
14
- }
15
- return (<main><form onSubmit={onSubmit}><textarea value={prompt} onChange={e=>setPrompt(e.target.value)}/><button disabled={loading}>Generar</button></form><pre>{result}</pre></main>)
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
client/src/pages/home.txs DELETED
@@ -1,43 +0,0 @@
1
- import React, { useState } from 'react'
2
- import { generateText } from '../api/hfClient'
3
-
4
- export default function Home(): JSX.Element {
5
- const [prompt, setPrompt] = useState('')
6
- const [result, setResult] = useState<string | null>(null)
7
- const [loading, setLoading] = useState(false)
8
-
9
- async function onSubmit(e: React.FormEvent) {
10
- e.preventDefault()
11
- setLoading(true)
12
- setResult(null)
13
- try {
14
- const r = await generateText(prompt)
15
- setResult(r)
16
- } catch (err) {
17
- setResult('Error: ' + String(err))
18
- } finally {
19
- setLoading(false)
20
- }
21
- }
22
-
23
- return (
24
- <main style={{ padding: 20, fontFamily: 'system-ui, sans-serif' }}>
25
- <h1>Hugging Face — proxy demo</h1>
26
- <form onSubmit={onSubmit}>
27
- <textarea
28
- value={prompt}
29
- onChange={(e) => setPrompt(e.target.value)}
30
- rows={6}
31
- cols={60}
32
- />
33
- <div style={{ marginTop: 8 }}>
34
- <button type="submit" disabled={loading}>Generar</button>
35
- </div>
36
- </form>
37
- <section style={{ marginTop: 20 }}>
38
- <h2>Resultado</h2>
39
- {loading ? <div>Generando...</div> : <pre>{result}</pre>}
40
- </section>
41
- </main>
42
- )
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
client/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends":"../tsconfig.json",
3
- "compilerOptions":{
4
- "jsx":"react-jsx",
5
- "baseUrl":"./",
6
- "paths":{}
7
- },
8
- "include":["src"]
9
- }
 
 
 
 
 
 
 
 
 
 
client/vite.config.ts DELETED
@@ -1,3 +0,0 @@
1
- import { defineConfig } from 'vite'
2
- import react from '@vitejs/plugin-react'
3
- export default defineConfig({ plugins:[react()], server:{ port:5173 } })