Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import main # main.py์ ์์ฑ๋ ์ ์ฒ๋ฆฌ ๋ก์ง ํธ์ถ | |
| import os | |
| import pandas as pd | |
| def process_file(file_path, voucher_number): | |
| if file_path is None: | |
| return None | |
| # ํ์ผ ํ์ฅ์ ํ์ธ | |
| ext = os.path.splitext(file_path)[1].lower() | |
| if ext == ".xlsx": | |
| # ์์ ํ์ผ์ CSV๋ก ๋ณํ | |
| df = pd.read_excel(file_path) | |
| csv_path = file_path.replace(".xlsx", ".csv") | |
| df.to_csv(csv_path, index=False) | |
| input_path = csv_path | |
| else: | |
| # ์ด๋ฏธ CSV ํ์ผ์ด๋ฉด ๊ทธ๋๋ก ์ฌ์ฉ | |
| input_path = file_path | |
| # ๋ฉ์ธ ์ ์ฒ๋ฆฌ ํจ์ ํธ์ถ (์ ํ๋ฒํธ ๋๊ฒจ์ฃผ๊ธฐ) | |
| output_path = main.process_rental_company_with_voucher(input_path, voucher_number) | |
| return output_path | |
| # Gradio ์ธํฐํ์ด์ค ๊ตฌ์ฑ | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# ERP ์๋ ์ ํ ๋ณํ๊ธฐ\n\n์ ๋ก๋ํ ํ์ผ๊ณผ ์ ํ๋ฒํธ๋ฅผ ์ ๋ ฅํ์ธ์.") | |
| with gr.Row(): | |
| file_input = gr.File( | |
| label="๋ ํ๋ฃ ํ์ผ ์ ๋ก๋ (CSV ๋๋ Excel)", | |
| file_types=[".csv", ".xlsx"], | |
| type="filepath" # โญ ์ฌ๊ธฐ๊ฐ ์ค์! | |
| ) | |
| voucher_input = gr.Textbox( | |
| label="์ ํ๋ฒํธ ์ ๋ ฅ", | |
| placeholder="์: 20250427001" | |
| ) | |
| with gr.Row(): | |
| submit_btn = gr.Button("์ ์ถ") | |
| clear_btn = gr.Button("์ง์ฐ๊ธฐ") | |
| output_file = gr.File(label="์ ์ฒ๋ฆฌ ์๋ฃ ํ์ผ ๋ค์ด๋ก๋") | |
| # ๋ฒํผ ํด๋ฆญ ์ด๋ฒคํธ ์ฐ๊ฒฐ | |
| submit_btn.click( | |
| fn=process_file, | |
| inputs=[file_input, voucher_input], | |
| outputs=output_file | |
| ) | |
| clear_btn.click( | |
| fn=lambda: (None, ""), | |
| inputs=[], | |
| outputs=[file_input, voucher_input] | |
| ) | |
| demo.launch() | |