Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Textfeld mit FastAPI</title> | |
| </head> | |
| <body> | |
| <h1>Textfeld mit FastAPI</h1> | |
| <form id="myForm"> | |
| <label for="prompt">Prompt:</label> | |
| <input type="text" id="prompt" name="prompt"> | |
| <button type="button" onclick="sendData()">Senden</button> | |
| </form> | |
| <script> | |
| async function sendData() { | |
| const prompt = document.getElementById("prompt").value; | |
| const zeitstempel = Math.floor(Date.now() / 1000); // Unix-Zeitstempel | |
| const data = { | |
| prompt: prompt, | |
| zeitstempel: zeitstempel | |
| }; | |
| const response = await fetch("https://huggingface.co/spaces/mgokg.hf.space/items/", { | |
| method: "POST", | |
| headers: { | |
| "Content-Type": "application/json" | |
| "Access-Control-Allow-Origin": "*" | |
| }, | |
| body: JSON.stringify(data) | |
| }); | |
| const result = await response.json(); | |
| alert(result) | |
| console.log(result); | |
| } | |
| </script> | |
| </body> | |
| </html> | |