Spaces:
Sleeping
Sleeping
louiecerv
commited on
Commit
·
25928ec
1
Parent(s):
b9e40e6
saved changes
Browse files- __pycache__/app.cpython-313.pyc +0 -0
- app.py +103 -0
- requirements.txt +1 -0
__pycache__/app.cpython-313.pyc
ADDED
Binary file (3.86 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
# Initialize a dictionary to store account information
|
5 |
+
accounts = {
|
6 |
+
"12345": {"name": "John Doe", "balance": 1000.0},
|
7 |
+
"67890": {"name": "Jane Doe", "balance": 500.0}
|
8 |
+
}
|
9 |
+
|
10 |
+
# Function to create a new account
|
11 |
+
def create_account(account_number, name, initial_balance):
|
12 |
+
if account_number in accounts:
|
13 |
+
return "Account number already exists."
|
14 |
+
else:
|
15 |
+
accounts[account_number] = {"name": name, "balance": initial_balance}
|
16 |
+
return "Account created successfully."
|
17 |
+
|
18 |
+
# Function to deposit money into an account
|
19 |
+
def deposit(account_number, amount):
|
20 |
+
if account_number in accounts:
|
21 |
+
accounts[account_number]["balance"] += amount
|
22 |
+
return f"Deposit successful. New balance: {accounts[account_number]['balance']}"
|
23 |
+
else:
|
24 |
+
return "Account number not found."
|
25 |
+
|
26 |
+
# Function to withdraw money from an account
|
27 |
+
def withdraw(account_number, amount):
|
28 |
+
if account_number in accounts:
|
29 |
+
if accounts[account_number]["balance"] >= amount:
|
30 |
+
accounts[account_number]["balance"] -= amount
|
31 |
+
return f"Withdrawal successful. New balance: {accounts[account_number]['balance']}"
|
32 |
+
else:
|
33 |
+
return "Insufficient balance."
|
34 |
+
else:
|
35 |
+
return "Account number not found."
|
36 |
+
|
37 |
+
# Function to check account balance
|
38 |
+
def check_balance(account_number):
|
39 |
+
if account_number in accounts:
|
40 |
+
return f"Account balance: {accounts[account_number]['balance']}"
|
41 |
+
else:
|
42 |
+
return "Account number not found."
|
43 |
+
|
44 |
+
# Gradio interface
|
45 |
+
demo = gr.Blocks()
|
46 |
+
|
47 |
+
with demo:
|
48 |
+
gr.Markdown("# Simple Banking System")
|
49 |
+
|
50 |
+
# Create account tab
|
51 |
+
with gr.Tab("Create Account"):
|
52 |
+
account_number = gr.Textbox(label="Account Number")
|
53 |
+
name = gr.Textbox(label="Name")
|
54 |
+
initial_balance = gr.Number(label="Initial Balance")
|
55 |
+
create_account_button = gr.Button("Create Account")
|
56 |
+
create_account_output = gr.Textbox(label="Output")
|
57 |
+
|
58 |
+
create_account_button.click(
|
59 |
+
create_account,
|
60 |
+
inputs=[account_number, name, initial_balance],
|
61 |
+
outputs=create_account_output
|
62 |
+
)
|
63 |
+
|
64 |
+
# Deposit tab
|
65 |
+
with gr.Tab("Deposit"):
|
66 |
+
account_number_deposit = gr.Textbox(label="Account Number")
|
67 |
+
amount_deposit = gr.Number(label="Amount")
|
68 |
+
deposit_button = gr.Button("Deposit")
|
69 |
+
deposit_output = gr.Textbox(label="Output")
|
70 |
+
|
71 |
+
deposit_button.click(
|
72 |
+
deposit,
|
73 |
+
inputs=[account_number_deposit, amount_deposit],
|
74 |
+
outputs=deposit_output
|
75 |
+
)
|
76 |
+
|
77 |
+
# Withdraw tab
|
78 |
+
with gr.Tab("Withdraw"):
|
79 |
+
account_number_withdraw = gr.Textbox(label="Account Number")
|
80 |
+
amount_withdraw = gr.Number(label="Amount")
|
81 |
+
withdraw_button = gr.Button("Withdraw")
|
82 |
+
withdraw_output = gr.Textbox(label="Output")
|
83 |
+
|
84 |
+
withdraw_button.click(
|
85 |
+
withdraw,
|
86 |
+
inputs=[account_number_withdraw, amount_withdraw],
|
87 |
+
outputs=withdraw_output
|
88 |
+
)
|
89 |
+
|
90 |
+
# Check balance tab
|
91 |
+
with gr.Tab("Check Balance"):
|
92 |
+
account_number_balance = gr.Textbox(label="Account Number")
|
93 |
+
check_balance_button = gr.Button("Check Balance")
|
94 |
+
balance_output = gr.Textbox(label="Output")
|
95 |
+
|
96 |
+
check_balance_button.click(
|
97 |
+
check_balance,
|
98 |
+
inputs=[account_number_balance],
|
99 |
+
outputs=balance_output
|
100 |
+
)
|
101 |
+
|
102 |
+
# Launch the Gradio app
|
103 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
gradio
|