|
import io, sys, os |
|
import gradio as gr |
|
import time |
|
import sys |
|
import io |
|
|
|
def display_log_window(): |
|
def display_stdout(): |
|
while True: |
|
yield stdout_buffer.getvalue() |
|
time.sleep(1) |
|
|
|
with gr.Blocks() as demo: |
|
with gr.Row(): |
|
with gr.Column(visible=True) as sidebar: |
|
output = gr.Textbox(interactive=False, lines=10, max_lines=20, show_label=False, elem_classes="log-window") |
|
demo.load(display_stdout, outputs=output) |
|
|
|
demo.queue().launch(server_port=9000) |
|
|
|
stdout_buffer = io.StringIO() |
|
sys.stdout = stdout_buffer |
|
|
|
|
|
def get_credentials(use_own_creds: bool): |
|
HIVEMQ_USERNAME = os.environ.get("HIVEMQ_USERNAME") |
|
HIVEMQ_PASSWORD = os.environ.get("HIVEMQ_PASSWORD") |
|
HIVEMQ_HOST = os.environ.get("HIVEMQ_HOST") |
|
DEVICE_ENDPOINT = os.environ.get("DEVICE_ID") |
|
PORT = int(os.environ.get("PORT", 8883)) |
|
return HIVEMQ_USERNAME, HIVEMQ_PASSWORD, HIVEMQ_HOST, DEVICE_ENDPOINT, PORT |