Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import subprocess
|
3 |
import pandas as pd
|
4 |
-
|
5 |
-
|
6 |
-
def run_cobol_binary(action, data):
|
7 |
-
result = subprocess.run(
|
8 |
-
["./cobol/account", action, data],
|
9 |
-
capture_output=True,
|
10 |
-
text=True
|
11 |
-
)
|
12 |
-
return result.stdout or result.stderr
|
13 |
|
14 |
def create_account(number, name, balance):
|
15 |
input_str = f"{number},{name},{balance}"
|
@@ -34,13 +26,17 @@ def export_loans():
|
|
34 |
return path
|
35 |
|
36 |
def get_log():
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
44 |
|
45 |
with gr.Blocks(title="COBOL Bank Demo", css="file=static/style.css") as demo:
|
46 |
gr.Markdown("# 💰 COBOL Banking System\nCreate, read, and export accounts and loans")
|
@@ -72,7 +68,7 @@ with gr.Blocks(title="COBOL Bank Demo", css="file=static/style.css") as demo:
|
|
72 |
exp_loan_btn.click(fn=export_loans, outputs=exp_loan_file)
|
73 |
|
74 |
with gr.Tab("Transaction Log"):
|
75 |
-
log_box = gr.HTML(label="Logs", value=get_log)
|
76 |
refresh_btn = gr.Button("Refresh Log")
|
77 |
refresh_btn.click(fn=get_log, outputs=log_box)
|
78 |
|
|
|
1 |
import gradio as gr
|
2 |
import subprocess
|
3 |
import pandas as pd
|
4 |
+
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
def create_account(number, name, balance):
|
7 |
input_str = f"{number},{name},{balance}"
|
|
|
26 |
return path
|
27 |
|
28 |
def get_log():
|
29 |
+
try:
|
30 |
+
with open("data/transactions.log", "r") as f:
|
31 |
+
content = f.read()
|
32 |
+
html_content = content.replace('\n', '<br>')
|
33 |
+
return f"""
|
34 |
+
<div class="transaction-log">
|
35 |
+
{html_content}
|
36 |
+
</div>
|
37 |
+
"""
|
38 |
+
except Exception as e:
|
39 |
+
return f"<div class='transaction-log'>Error reading log: {str(e)}</div>"
|
40 |
|
41 |
with gr.Blocks(title="COBOL Bank Demo", css="file=static/style.css") as demo:
|
42 |
gr.Markdown("# 💰 COBOL Banking System\nCreate, read, and export accounts and loans")
|
|
|
68 |
exp_loan_btn.click(fn=export_loans, outputs=exp_loan_file)
|
69 |
|
70 |
with gr.Tab("Transaction Log"):
|
71 |
+
log_box = gr.HTML(label="Logs", value=get_log())
|
72 |
refresh_btn = gr.Button("Refresh Log")
|
73 |
refresh_btn.click(fn=get_log, outputs=log_box)
|
74 |
|