File size: 909 Bytes
8565ad0
 
 
 
8ea54ed
09037cb
8565ad0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr

import os

GRADIO_PORT = os.getenv("GRADIO_PORT") or 7860
GRADIO_SHARE = os.getenv("GRADIO_SHARE") or False
GRADIO_DEBUG = os.getenv("GRADIO_DEBUG") or True

SDT_PLACEHOLDER = os.getenv("SDT_PLACEHOLDER") or "Ctrl-Shift to get a response..."
SDT_LABEL = os.getenv("SDT_LABEL") or "Dyanmic Text ( Shift-Enter to send )"
SDT_LINES = os.getenv("SDT_LINES") or "\n"*16

INITIAL_STATE = {
    "html": f"""
<h1>Welcome</h1>
"""
}

def greeting(inpt):
    return "<strong>You Said</strong>, <p>" + inpt.strip() + "</p>!\n\n"

with gr.Blocks() as dmo:
    with gr.Row():
        output = gr.HTML(INITIAL_STATE['html'])
    with gr.Row():
        inpt = gr.Textbox(SDT_LINES, placeholder=SDT_PLACEHOLDER, label=SDT_LABEL, lines=len(SDT_LINES))
        inpt.submit(greeting, inputs=[inpt], outputs=[inpt])
    dmo.launch(share=GRADIO_SHARE, debug=GRADIO_DEBUG, inline=True, server_port=GRADIO_PORT)