Spaces:
Runtime error
Runtime error
| import argparse | |
| import csv | |
| import gradio as gr | |
| import json | |
| import os | |
| import pandas as pd | |
| import requests | |
| from datetime import datetime | |
| from io import StringIO | |
| region_choices = ['us', 'ko'] | |
| user_portfolio_output_path = "used_user.csv" | |
| json_example_output_path = "output_example.json" | |
| json_new_output_path = "output.json" | |
| report_example_output_path = "report_example.txt" | |
| report_new_output_path = "report.txt" | |
| def make_user_csv(csv_text, top_n): | |
| """ ์ฌ์ฉ์ ํฌํธํด๋ฆฌ์ค๋ฅผ top_n๋ง user_portfolio_output_path์ ์ ์ฅ""" | |
| df = load_portfolio_to_df(csv_text) | |
| df['๋งค์ ์ฃผ๊ฐ'] = df['๋งค์ ์ฃผ๊ฐ'].astype(float) | |
| df['๋ณด์ ์ฃผ์์'] = df['๋ณด์ ์ฃผ์์'].astype(float) | |
| df['๋งค์ ๊ธ์ก'] = df['๋งค์ ์ฃผ๊ฐ'] * df['๋ณด์ ์ฃผ์์'] | |
| df_sorted = df.sort_values(by='๋งค์ ๊ธ์ก', ascending=False) | |
| df_top = df_sorted.head(top_n) | |
| df_top = df_top[['์ข ๋ชฉ์ฝ๋', '์ข ๋ชฉ๋ช ', '๋งค์ ์ฃผ๊ฐ', '๋ณด์ ์ฃผ์์']] | |
| df_top.to_csv(user_portfolio_output_path, index=False, encoding='utf-8-sig') | |
| return df_top # ๋ฐํ๊ฐ DataFrame | |
| def load_portfolio_to_df(csv_text): | |
| """csv_text๋ฅผ pandas DataFrame์ผ๋ก ๋ณํํ์ฌ ๋ฐํ""" | |
| if isinstance(csv_text, str) and os.path.exists(csv_text): | |
| return pd.read_csv(csv_text, dtype=str) | |
| if isinstance(csv_text, str): | |
| try: | |
| return pd.read_csv(StringIO(csv_text), dtype=str) | |
| except Exception as e: | |
| raise ValueError(f"CSV ๋ฌธ์์ด์ DataFrame์ผ๋ก ๋ณํ ์คํจ: {e}") | |
| if isinstance(csv_text, pd.DataFrame): | |
| return csv_text.copy() | |
| raise ValueError("csv_text๋ CSV ํ์ผ ๊ฒฝ๋ก, CSV ๋ฌธ์์ด ๋๋ DataFrame์ด์ด์ผ ํฉ๋๋ค.") | |
| def parse_csv(csv_text): | |
| """CSV ํ ์คํธ โ ์ข ๋ชฉ์ฝ๋ ๋ฆฌ์คํธ""" | |
| try: | |
| df = pd.read_csv(StringIO(csv_text)) | |
| except Exception: | |
| return {"error": "csv_parse_failed", "detail": "CSV ํ์์ด ์๋ชป๋์์ต๋๋ค."} | |
| if "์ข ๋ชฉ์ฝ๋" not in df.columns: | |
| return {"error": "missing_column", "detail": "'์ข ๋ชฉ์ฝ๋' ์ปฌ๋ผ์ด ์์ต๋๋ค."} | |
| stock_list = df["์ข ๋ชฉ์ฝ๋"].astype(str).tolist() | |
| return stock_list | |
| def request_post(base_url: str, service: str, req_body: dict): | |
| try: | |
| url = f'{base_url}/{service}' | |
| res = requests.post( | |
| url=url, | |
| json=req_body | |
| ) | |
| res.raise_for_status() | |
| except Exception as e: | |
| print(f'[ERROR] {service} / ์๋ฌ ๋ฐ์: {str(e)}') | |
| res_body = res.json() | |
| if res_body['success']: | |
| return res_body['data'] | |
| def remove_duplicates(data_list): | |
| """stock ํค๊ฐ ๊ธฐ์ค์ผ๋ก ์ค๋ณต ์ ๊ฑฐ""" | |
| seen = set() | |
| unique_list = [] | |
| for item in data_list: | |
| stock_name = item.get('stock') | |
| if stock_name and stock_name not in seen: | |
| seen.add(stock_name) | |
| unique_list.append(item) | |
| return unique_list | |
| def fetch_example_data(): | |
| """json_example_output_path ๊ฒฝ๋ก์ JSON ํ์ผ์ ์ฝ์ด dict ํํ๋ก ๋ฐํ""" | |
| if not os.path.exists(json_example_output_path): | |
| print(f"[ERROR] ํ์ผ์ด ์กด์ฌํ์ง ์์ต๋๋ค: {json_example_output_path}") | |
| return None | |
| try: | |
| user_name = "์ด์์ค" | |
| region = 'us' | |
| user_csv = """์ข ๋ชฉ์ฝ๋,์ข ๋ชฉ๋ช ,๋งค์ ์ฃผ๊ฐ,๋ณด์ ์ฃผ์์ | |
| NVDA,NVIDIA Corporation,159.69,167 | |
| AMZN,"Amazon.com, Inc.",211.58,140 | |
| MSFT,Microsoft Corporation,527.99,131 | |
| AAPL,Apple Inc.,258.45,116 | |
| GOOGL,Alphabet Inc.,262.59,97 | |
| """ | |
| processed_csv = make_user_csv(user_csv, top_n=5) | |
| processed_csv.to_csv(user_portfolio_output_path, index=False, encoding="utf-8") | |
| with open(user_portfolio_output_path, "r", encoding="utf-8") as f: | |
| csv_data = f.read() | |
| with open(json_example_output_path, "r", encoding="utf-8") as f: | |
| json_data = json.load(f) | |
| return user_name, region, csv_data, json_data | |
| except Exception as e: | |
| print(f"[ERROR] process_user_data ์ค๋ฅ: {e}") | |
| return "", [], "", {} | |
| def update_user_with_stock_price(json_data, res_data): | |
| """ | |
| res_data ๋ก ๋ฐ์ stock_price ์ ๋ณด๋ฅผ ๊ธฐ๋ฐ์ผ๋ก | |
| json_data["user"] ํญ๋ชฉ์ ํ์ฌ์ฃผ๊ฐ, ์์ต๋ฅ , ํ์ฌ์์ฐ์ ์ ๋ฐ์ดํธ | |
| """ | |
| def normalize(code): | |
| return str(code).strip().upper() | |
| # user ๋ชฉ๋ก ๊ฐ์ ธ์ค๊ธฐ | |
| user_list = json_data.get("user", []) | |
| if not isinstance(user_list, list): | |
| print("[WARN] user ๋ฐ์ดํฐ ๊ตฌ์กฐ๊ฐ list ์๋ โ ์ ๋ฐ์ดํธ ๋ถ๊ฐ") | |
| return | |
| # ์ข ๋ชฉ ๊ฐ๊ฒฉ dict(normalized) | |
| stock_price_map = {normalize(k): v for k, v in res_data.items()} | |
| # user ๊ฐ ํญ๋ชฉ ์ ๋ฐ์ดํธ | |
| for user_item in user_list: | |
| raw_code = user_item.get("์ข ๋ชฉ์ฝ๋") | |
| if not raw_code: | |
| continue | |
| code = normalize(raw_code) | |
| # stock_price ์ ํด๋น ์ข ๋ชฉ์ด ์กด์ฌํ๋์ง ํ์ธ | |
| prices = stock_price_map.get(code) | |
| if not prices: | |
| print(f"[WARN] {code} ์ข ๋ชฉ์ ์ฃผ๊ฐ ๋ฐ์ดํฐ ์์ โ user ์ถ๊ฐ์ ๋ณด ์คํต") | |
| continue | |
| # ์ต์ ์ข ๊ฐ (list ๋ง์ง๋ง) | |
| last_row = prices[-1] | |
| try: | |
| current_price = float(last_row.get("Close")) | |
| buy_price = float(user_item.get("๋งค์ ์ฃผ๊ฐ")) | |
| qty = float(user_item.get("๋ณด์ ์ฃผ์์")) | |
| except Exception: | |
| print(f"[WARN] {code} ๊ฐ ๋ณํ ์ค๋ฅ โ user ์ถ๊ฐ์ ๋ณด ์คํต") | |
| continue | |
| # ์์ต๋ฅ ๊ณ์ฐ | |
| profit_rate = round(((current_price - buy_price) / buy_price) * 100, 2) | |
| current_asset = round(current_price * qty, 2) | |
| # ์ ๋ฐ์ดํธ | |
| user_item["ํ์ฌ์ฃผ๊ฐ"] = str(current_price) | |
| user_item["์์ต๋ฅ "] = f"{profit_rate}%" | |
| user_item["ํ์ฌ์์ฐ"] = str(current_asset) | |
| # ์ ์ฅ | |
| json_data["user"] = user_list | |
| return json_data | |
| def fetch_new_data(region, csv_text, server_url): | |
| """API ์คํ: ์ ์ฌ ํฌ์์ ๋ฐ์ดํฐ ์์ฒญ ํ JSON ๋ฐํ""" | |
| try: | |
| final_json = {} | |
| portfolio = make_user_csv(csv_text, top_n=5) # user_portfolio_output_path ์ ์ฅ | |
| # =========================== | |
| # 1. ์ ์ฌ ํฌ์ํ์ฌ API | |
| # =========================== | |
| service = 'similar_investors' | |
| req_body = { | |
| 'csv_text': portfolio.to_csv(index=False), | |
| 'region': region[0] if isinstance(region, list) else region, | |
| 'top': 5 | |
| } | |
| print(f"[INFO] ์ ์ฌ ํฌ์์ {req_body['top']}๊ฐ ์์ง ์์..") | |
| res_data = request_post(server_url, service, req_body) | |
| if not res_data: | |
| print(f'[ERROR] ์ ์ฌ ํฌ์์ ์์ง ์คํจ..') | |
| return None | |
| print(f'[INFO] ์ ์ฌ ํฌ์์ ์์ง ์๋ฃ:', res_data) | |
| final_json[service] = res_data | |
| # user ํค ์ ์ฅ | |
| used_user_csv = portfolio.to_csv(index=False) | |
| f = StringIO(used_user_csv) | |
| reader = csv.reader(f) | |
| rows = list(reader) | |
| if not rows or len(rows) < 2: | |
| print("[WARN] portfolio CSV ๋ด์ฉ์ด ๋น์ด ์์ด user ๋ฐ์ดํฐ ์ ์ฅ์ ์๋ตํฉ๋๋ค.") | |
| final_json["user"] = [] | |
| else: | |
| headers = rows[0] | |
| user_list = [dict(zip(headers, cols)) for cols in rows[1:]] | |
| final_json["user"] = user_list | |
| # ์ฐ์ , ํ ๋ง ์์ฒญ์ ํฌ์์ ์ข ๋ชฉ๋ ํฌํจ | |
| si_names = list(set([d['NAME'] for rows in res_data.values() for d in rows])) | |
| si_companies = list(set([d['COMPANY'] for rows in res_data.values() for d in rows])) | |
| # =========================== | |
| # 2. ์ ์ฌ ํฌ์ํ์ฌ ์ค๋ช API | |
| # =========================== | |
| print("[INFO] ํฌ์ํ์ฌ name ๋ชฉ๋ก:", si_names) | |
| final_json["investment_company"] = {} | |
| service = "investment_company" | |
| for name in si_names: | |
| print(f"[INFO] {name} ์ค๋ช ์์ง ์์..") | |
| req_body = {"name": name} | |
| res_data = request_post(server_url, service, req_body) | |
| if not res_data: | |
| print("[ERROR] ์ค๋ช ์์ง ์คํจ:", name) | |
| final_json[service][name] = { | |
| "error": True, | |
| "detail": "request_post failed" | |
| } | |
| continue | |
| print("[INFO] ์ค๋ช ์์ง ์๋ฃ:", res_data) | |
| final_json[service][name] = res_data | |
| if not final_json[service]: | |
| print(f'[ERROR] ์ ์ฌ ํฌ์์ ์์ง ์คํจ..') | |
| return None | |
| # =========================== | |
| # 3. ์ฐ์ ๊ตฐ API | |
| # =========================== | |
| service = 'industry_info' | |
| stock = portfolio['์ข ๋ชฉ์ฝ๋'].to_list() + si_companies | |
| req_body = { | |
| 'stock': stock | |
| } | |
| print(f'[INFO] ์ฐ์ ์ ๋ณด {",".join(stock)} ์์ง ์์..') | |
| res_data = request_post(server_url, service, req_body) | |
| if not res_data: | |
| print(f'[ERROR] ์ฐ์ ์ ๋ณด ์์ง ์คํจ..') | |
| return None | |
| print(f'[INFO] ์ฐ์ ์ ๋ณด ์์ง ์๋ฃ:', res_data) | |
| res_data = remove_duplicates(res_data) | |
| final_json[service] = res_data | |
| # =========================== | |
| # 4. ํ ๋ง API | |
| # =========================== | |
| service = 'theme_info' | |
| stock = portfolio['์ข ๋ชฉ์ฝ๋'].to_list() + si_companies | |
| req_body = { | |
| 'stock': stock | |
| } | |
| print(f'[INFO] ํ ๋ง์ ๋ณด {",".join(stock)} ์์ง ์์..') | |
| res_data = request_post(server_url, service, req_body) | |
| if not res_data: | |
| print(f'[ERROR] ํ ๋ง์ ๋ณด ์์ง ์คํจ..') | |
| return None | |
| print(f'[INFO] ํ ๋ง์ ๋ณด ์์ง ์๋ฃ:', res_data) | |
| res_data = remove_duplicates(res_data) | |
| final_json[service] = res_data | |
| # =========================== | |
| # 5. ์ฃผ๊ฐ API | |
| # =========================== | |
| service = 'stock_price' | |
| stock = ','.join(portfolio['์ข ๋ชฉ์ฝ๋']) | |
| req_body = {'stock': stock} | |
| print(f'[INFO] ์ข ๋ชฉ๊ฐ๊ฒฉ {stock} ์์ง ์์..') | |
| res_data = request_post(server_url, service, req_body) | |
| if not res_data: | |
| print(f'[ERROR] ์ข ๋ชฉ๊ฐ๊ฒฉ ์์ง ์คํจ..') | |
| return None | |
| print(f'[INFO] ์ข ๋ชฉ๊ฐ๊ฒฉ ์์ง ์๋ฃ:', res_data) | |
| final_json[service] = res_data | |
| update_user_with_stock_price(final_json, res_data) | |
| # =========================== | |
| # 6. ๋ด์ค API | |
| # =========================== | |
| service = 'stock_news' | |
| for stock in portfolio['์ข ๋ชฉ์ฝ๋']: | |
| print(f'[INFO] ์ข ๋ชฉ๋ด์ค {stock} ์์ง ์์..') | |
| req_body = { | |
| 'stock': stock, | |
| 'period': 7 | |
| } | |
| res_data = request_post(server_url, service, req_body) | |
| if res_data: | |
| print(f'[INFO] ์ข ๋ชฉ๋ด์ค {stock} ์์ง ์๋ฃ:', res_data) | |
| final_json.setdefault(service, {}) | |
| if isinstance(res_data, dict): | |
| final_json[service].update(res_data) | |
| else: | |
| final_json[service][stock] = res_data | |
| else: | |
| print(f'[ERROR] ์ข ๋ชฉ๋ด์ค {stock} ์์ง ์คํจ..') | |
| if not final_json.get(service): | |
| print(f'[ERROR] ์ข ๋ชฉ๋ด์ค ์์ง ์คํจ..') | |
| return None | |
| try: | |
| with open(json_new_output_path, "w", encoding="utf-8") as f: | |
| json.dump(final_json, f, ensure_ascii=False, indent=4) | |
| print(f"[INFO] {json_new_output_path}์ ์ ์ฅ ์๋ฃ") | |
| except Exception as e: | |
| print(f"[ERROR] {json_new_output_path} ์ ์ฅ ์ค๋ฅ:", str(e)) | |
| return final_json | |
| except Exception as e: | |
| print("[ERROR] ์คํ ์ค ์ค๋ฅ:", str(e)) | |
| return {"error": "exception", "detail": str(e)} | |
| def load_report(): | |
| """report_example_output_path ๊ฒฝ๋ก์ txt ํ์ผ์ ์ฝ์ด ๋ฌธ์์ด๋ก ๋ฐํ""" | |
| if not os.path.exists(report_example_output_path): | |
| print(f"[ERROR] ํ์ผ์ด ์กด์ฌํ์ง ์์ต๋๋ค: {report_example_output_path}") | |
| return "" | |
| try: | |
| with open(report_example_output_path, "r", encoding="utf-8") as f: | |
| data = f.read() | |
| return data | |
| except Exception as e: | |
| print(f"[ERROR] ํ์ผ ์ฝ๊ธฐ ์ค ์ค๋ฅ ๋ฐ์: {e}") | |
| return "" | |
| def generate_report(user_name, server_url, json): | |
| """์ต์ข ๋ฆฌํฌํธ ์์ฑ API ํธ์ถ โ user_name, csv, json ์ ๋ ฅ""" | |
| try: | |
| print(f"[INFO] {user_name} ๋์ ์ํ ํฌํธํด๋ฆฌ์ค ๋ถ์ ๋ฆฌํฌํธ ์์ฑ") | |
| with open(user_portfolio_output_path, "r", encoding="utf-8") as f: | |
| csv_text = f.read() | |
| payload = { | |
| "date": datetime.now().strftime("%Y-%m-%d"), # ๋ฆฌํฌํธ ์์ฑ ๋ ์ง (๊ธฐ๋ณธ: ์ค๋ ๋ ์ง) | |
| "user_name": user_name, | |
| "csv_text": csv_text, | |
| "json_text": json | |
| } | |
| print("[INFO] ์ ๋ ฅ๋ฐ์ดํฐ ๋ก๋ ์๋ฃ") | |
| print("[INFO] ๋ฆฌํฌํธ ์์ฑ ์ค ... ") | |
| resp = requests.post(f"{server_url}/report", json=payload) | |
| if resp.status_code != 200: | |
| return f"โ ๋ฆฌํฌํธ ์์ฑ ์คํจ: {resp.text}" | |
| data = resp.json() | |
| report_md = data["data"]["report"] | |
| print("[INFO] ๋ฆฌํฌํธ ์์ฑ ์๋ฃ") | |
| with open(report_new_output_path, "w", encoding="utf-8") as f: | |
| f.write(report_md) | |
| print(f"[INFO] {report_new_output_path}์ ์ ์ฅ ์๋ฃ\n") | |
| return report_md | |
| except FileNotFoundError: | |
| return f"โ ์ค๋ฅ: {user_portfolio_output_path} ํ์ผ์ ์ฐพ์ ์ ์์ต๋๋ค." | |
| except Exception as e: | |
| return f"โ ์ค๋ฅ ๋ฐ์: {str(e)}" | |
| def enforce_single(selection): | |
| """ | |
| selection: ํ์ฌ ์ฒดํฌ๋ ๋ฆฌ์คํธ (None or list) | |
| ๋ฐํ๊ฐ: ๋ฐ๋์ 1๊ฐ๋ง ๋ด๊ธด ๋ฆฌ์คํธ | |
| """ | |
| # ์ฌ์ฉ์ ์ ๋ ฅ์ด None ์ด๊ฑฐ๋ ๋น์ด์์ผ๋ฉด ๊ธฐ๋ณธ๊ฐ ๋ฐํ | |
| if not selection: | |
| return [region_choices[0]] | |
| # ์ฌ๋ฌ๊ฐ ์ ํ๋ ๊ฒฝ์ฐ ๋ง์ง๋ง ์ ํํ ํญ๋ชฉ๋ง ๋จ๊น | |
| if len(selection) > 1: | |
| return [selection[-1]] | |
| # ์ด๋ฏธ 1๊ฐ๋ฉด ๊ทธ๋๋ก ๋ฐํ | |
| return selection | |
| def main(): | |
| parser = argparse.ArgumentParser(description="Web Client") | |
| parser.add_argument("--port", default=7864, type=int, help="Port number to run the Gradio app") | |
| parser.add_argument("--server-url", default="http://localhost:8080" , type=str, help="Server url to run the app") | |
| args = parser.parse_args() | |
| with gr.Blocks() as app: | |
| gr.Markdown("# ํฌํธํด๋ฆฌ์ค ๋ถ์ ๋ฆฌํฌํธ ๐ ") | |
| server_url = gr.State(args.server_url) | |
| with gr.Row(scale=1): | |
| with gr.Column(scale=1): | |
| gr.Markdown("### 1. ์ฌ์ฉ์ ์ด๋ฆ์ ์ ๋ ฅํ์ธ์.") | |
| user_name = gr.Textbox(value="์ด์์ค", placeholder="์: ์ด์์ค ", show_label=False) | |
| with gr.Column(scale=1): | |
| gr.Markdown("") | |
| with gr.Row(scale=1): | |
| with gr.Column(scale=1): | |
| gr.Markdown("### 2. ์ฌ์ฉ์ ํฌํธํด๋ฆฌ์ค๋ฅผ ์ ๋ ฅํ์ธ์.") | |
| region_checkbox = gr.CheckboxGroup(choices=region_choices, value=[region_choices[0]], label="๋น์ ์ ํฌํธํด๋ฆฌ์ค์ ๊ฐ์ฅ ๋ถํฉํ๋ ์ง์ญ์ ์ ํํ์ธ์.") | |
| region_checkbox.change(fn=enforce_single, inputs=region_checkbox, outputs=region_checkbox) | |
| csv_input = gr.Textbox( | |
| label="๋น์ ์ ํฌํธํด๋ฆฌ์ค๋ฅผ ์ ๋ ฅํ์ธ์. (CSVํ์) ", | |
| lines=7, | |
| max_lines=7, | |
| value="์ข ๋ชฉ์ฝ๋,์ข ๋ชฉ๋ช ,๋งค์ ์ฃผ๊ฐ,๋ณด์ ์ฃผ์์\n" | |
| "TSLA,Tesla Inc.,227.34,88\n" | |
| "META,Meta Platforms Inc.,484.12,52\n" | |
| "NFLX,Netflix Inc.,598.43,31\n" | |
| "AVGO,Broadcom Inc.,1421.77,12\n" | |
| "CRM,Salesforce Inc.,289.24,63", | |
| placeholder="์: \n" | |
| "์ข ๋ชฉ์ฝ๋,์ข ๋ชฉ๋ช ,๋งค์ ์ฃผ๊ฐ,๋ณด์ ์ฃผ์์\n" | |
| "TSLA,Tesla Inc.,227.34,88\n" | |
| "META,Meta Platforms Inc.,484.12,52\n" | |
| "NFLX,Netflix Inc.,598.43,31\n" | |
| "AVGO,Broadcom Inc.,1421.77,12\n" | |
| "CRM,Salesforce Inc.,289.24,63", | |
| interactive=True, | |
| show_label=True | |
| ) | |
| with gr.Column(scale=1): | |
| gr.Markdown("") | |
| with gr.Row(scale=1): | |
| with gr.Column(scale=1): | |
| gr.Markdown("### 3. ์ ๋ ฅ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ค์ธ์.") | |
| with gr.Row(scale=1): | |
| fetch_example_button = gr.Button("๊ธฐ์กด ์ ๋ ฅ ๋ฐ์ดํฐ ๊ฐ์ ธ์ค๊ธฐ") | |
| fetch_new_button = gr.Button("์๋ก์ด ์ ๋ ฅ ๋ฐ์ดํฐ ์์ฑํ๊ธฐ") | |
| with gr.Column(scale=1): | |
| gr.Markdown("### 4. ํฌํธํด๋ฆฌ์ค ๋ถ์ ๋ฆฌํฌํธ๋ฅผ ์์ฑํ์ธ์.") | |
| with gr.Row(scale=1): | |
| report_example_button = gr.Button("๊ธฐ์กด ๋ฆฌํฌํธ ๊ฐ์ ธ์ค๊ธฐ") | |
| report_new_button = gr.Button("์๋ก์ด ๋ฆฌํฌํธ ์์ฑํ๊ธฐ") | |
| with gr.Row(scale=1): | |
| json_output = gr.JSON(label="API ์๋ต(JSON)") | |
| report_output = gr.Markdown() | |
| fetch_example_button.click( | |
| fn=fetch_example_data, | |
| inputs=[], | |
| outputs=[user_name, region_checkbox, csv_input, json_output] | |
| ) | |
| fetch_new_button.click( | |
| fn=fetch_new_data, | |
| inputs=[region_checkbox, csv_input, server_url], | |
| outputs=[json_output] | |
| ) | |
| report_example_button.click( | |
| fn=load_report, | |
| inputs=[], | |
| outputs=[report_output] | |
| ) | |
| report_new_button.click( | |
| fn=generate_report, | |
| inputs=[user_name, server_url, json_output], | |
| outputs=[report_output] | |
| ) | |
| app.launch(theme='CultriX/gradio-theme', share=True, server_name="0.0.0.0", server_port=args.port, debug=True) | |
| if __name__ == "__main__": | |
| main() |