B2W1234 commited on
Commit
da00eb7
1 Parent(s): 52b5834

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -20
app.py CHANGED
@@ -1,9 +1,8 @@
1
- import streamlit as st
2
  from PIL import Image
3
  import requests
4
  import openpyxl
5
  from openpyxl import load_workbook
6
-
7
  all_content = []
8
 
9
  def append_to_excel(content):
@@ -80,6 +79,8 @@ def get_qr_code(context_bank):
80
 
81
  qr_image = Image.open("qr_code.png")
82
 
 
 
83
  return qr_image
84
 
85
  def display_info():
@@ -90,8 +91,8 @@ def display_info():
90
 
91
  # Ảnh QR code
92
 
 
93
  return account_name, account_number, content
94
-
95
  def check_payment_status(content):
96
  # Giả sử kiểm tra trạng thái thanh toán và trả về thông báo
97
  print("content", content)
@@ -104,21 +105,32 @@ def check_payment_status(content):
104
  else:
105
  return "Tao chưa nhận được xiền, gửi lại mau thồn lằng"
106
 
107
- # Streamlit UI
108
- st.title("Ứng dụng Chuyển Khoản")
109
- account_name, account_number, content = display_info()
110
-
111
- qr_image = st.empty()
112
- st.text_input("Tên tài khoản:", value=account_name)
113
- st.text_input("Số tài khoản:", value=account_number)
114
- content_input = st.text_input("Nội dung:", value="chuyển khoản")
115
- get_qr_button = st.button("Lấy mã qr")
116
- if get_qr_button:
117
- qr_image.image(get_qr_code(content_input), caption="QR Code")
118
 
119
- payment_status_output = st.empty()
120
- check_status_button = st.button("Check Trạng Thái Thanh Toán")
121
- if check_status_button:
122
- payment_status_output.text(check_payment_status(content_input))
123
-
124
- st.markdown("© 2024 Trần Đình Nhật")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
  from PIL import Image
3
  import requests
4
  import openpyxl
5
  from openpyxl import load_workbook
 
6
  all_content = []
7
 
8
  def append_to_excel(content):
 
79
 
80
  qr_image = Image.open("qr_code.png")
81
 
82
+
83
+
84
  return qr_image
85
 
86
  def display_info():
 
91
 
92
  # Ảnh QR code
93
 
94
+
95
  return account_name, account_number, content
 
96
  def check_payment_status(content):
97
  # Giả sử kiểm tra trạng thái thanh toán và trả về thông báo
98
  print("content", content)
 
105
  else:
106
  return "Tao chưa nhận được xiền, gửi lại mau thồn lằng"
107
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
+
110
+ # Tạo form Gradio
111
+ with gr.Blocks() as demo:
112
+ with gr.Row():
113
+ with gr.Column():
114
+ qr_image = gr.Image(label="QR Code", type="pil")
115
+ with gr.Column():
116
+ account_name = gr.Textbox(label="Tên tài khoản:", value="Trần Đình Nhật", interactive=False)
117
+ account_number = gr.Textbox(label="Số tài khoản:", value="738999918092007", interactive=False)
118
+ content = gr.Textbox(label="Nội dung:", value="chuyển khoản", interactive=True)
119
+
120
+ get_qr_button = gr.Button("Lấy mã qr")
121
+ get_qr_button.click(get_qr_code, inputs=content, outputs=qr_image)
122
+
123
+
124
+ payment_status_output = gr.Textbox(label="Trạng Thái Thanh Toán", interactive=False)
125
+ check_status_button = gr.Button("Check Trạng Thái Thanh Toán")
126
+ check_status_button.click(check_payment_status, inputs=content, outputs=payment_status_output)
127
+
128
+
129
+ with gr.Row():
130
+ gr.Markdown("© 2024 Trần Đình Nhật")
131
+ # Hiển thị thông tin và ảnh
132
+ get_qr_code(content)
133
+ demo.load(display_info, outputs=[account_name, account_number, content])
134
+
135
+ # Chạy ứng dụng
136
+ demo.launch(inline=False)