mgokg commited on
Commit
0fcfd7e
·
verified ·
1 Parent(s): b0228a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py CHANGED
@@ -34,7 +34,49 @@ prompt = ""
34
  def get_prompt(prompt):
35
  return prompt
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  with gr.Blocks() as demo:
 
38
  with gr.Row():
39
  #details_output = gr.DataFrame(label="Ausgabe", elem_id="md")
40
  details_output = gr.Textbox(label="Ausgabe")
 
34
  def get_prompt(prompt):
35
  return prompt
36
 
37
+
38
+ def show_html():
39
+ return """<!DOCTYPE html>
40
+ <html lang="en">
41
+ <head>
42
+ <meta charset="UTF-8">
43
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
44
+ <title>Textfeld mit FastAPI</title>
45
+ </head>
46
+ <body>
47
+ <h1>Textfeld mit FastAPI</h1>
48
+ <form id="myForm">
49
+ <label for="prompt">Prompt:</label>
50
+ <input type="text" id="prompt" name="prompt">
51
+ <button type="button" onclick="sendData()">Senden</button>
52
+ </form>
53
+
54
+ <script>
55
+ async function sendData() {
56
+ const prompt = document.getElementById("prompt").value;
57
+ const zeitstempel = Math.floor(Date.now() / 1000); // Unix-Zeitstempel
58
+ const data = {
59
+ prompt: prompt,
60
+ zeitstempel: zeitstempel
61
+ };
62
+ const response = await fetch("https://huggingface.co/spaces/mgokg.hf.space:8000", {
63
+ method: "POST",
64
+ headers: {
65
+ "Content-Type": "application/json"
66
+ },
67
+ body: JSON.stringify(data)
68
+ });
69
+ const result = await response.json();
70
+ alert(result)
71
+ console.log(result)
72
+ }
73
+ </script>
74
+ </body>
75
+ </html>
76
+ """
77
+
78
  with gr.Blocks() as demo:
79
+ gr.HTML(show_html)
80
  with gr.Row():
81
  #details_output = gr.DataFrame(label="Ausgabe", elem_id="md")
82
  details_output = gr.Textbox(label="Ausgabe")