Pontonkid commited on
Commit
9529223
ยท
verified ยท
1 Parent(s): 9c344ff

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -71
app.py DELETED
@@ -1,71 +0,0 @@
1
- import gradio as gr
2
- import requests
3
-
4
- # Expanded currency list with country codes and emojis
5
- CURRENCIES = {
6
- "USD": "United States Dollar ๐Ÿ‡บ๐Ÿ‡ธ",
7
- "EUR": "Euro ๐Ÿ‡ช๐Ÿ‡บ",
8
- "INR": "Indian Rupee ๐Ÿ‡ฎ๐Ÿ‡ณ",
9
- "GBP": "Pound Sterling ๐Ÿ‡ฌ๐Ÿ‡ง",
10
- "AUD": "Australian Dollar ๐Ÿ‡ฆ๐Ÿ‡บ",
11
- "CAD": "Canadian Dollar ๐Ÿ‡จ๐Ÿ‡ฆ",
12
- "JPY": "Japanese Yen ๐Ÿ‡ฏ๐Ÿ‡ต",
13
- "CNY": "Chinese Renminbi ๐Ÿ‡จ๐Ÿ‡ณ",
14
- "BRL": "Brazilian Real ๐Ÿ‡ง๐Ÿ‡ท",
15
- "ZAR": "South African Rand ๐Ÿ‡ฟ๐Ÿ‡ฆ",
16
- # Add more currencies as needed...
17
- }
18
-
19
- # Function to get exchange rate and convert currency
20
- def convert_currency(amount, from_currency, to_currency):
21
- url = f"https://v6.exchangerate-api.com/v6/YOUR-API-KEY/latest/{from_currency}"
22
- try:
23
- response = requests.get(url)
24
- data = response.json()
25
- if data['result'] != 'success':
26
- return f"Error: {data.get('error-type', 'Unknown error')}"
27
-
28
- rates = data["conversion_rates"]
29
- conversion_rate = rates[to_currency]
30
- converted_amount = float(amount) * conversion_rate
31
- return f"{amount} {from_currency} = {converted_amount:.2f} {to_currency}"
32
- except Exception as e:
33
- return f"Error: {str(e)}"
34
-
35
- # Define the Gradio interface
36
- def create_interface():
37
- with gr.Blocks() as interface:
38
- with gr.Row():
39
- gr.Markdown("<h1 style='text-align: center;'>Currency Converter with Emojis ๐ŸŒŽ๐Ÿ’ฐ</h1>")
40
-
41
- with gr.Row():
42
- amount = gr.Textbox(label="Amount", placeholder="Enter the amount to convert", elem_id="amount_input")
43
-
44
- with gr.Row():
45
- from_currency = gr.Dropdown(choices=list(CURRENCIES.keys()), label="From Currency", value="USD", elem_id="from_currency_input")
46
- to_currency = gr.Dropdown(choices=list(CURRENCIES.keys()), label="To Currency", value="EUR", elem_id="to_currency_input")
47
-
48
- with gr.Row():
49
- convert_button = gr.Button("Convert", elem_id="convert_button")
50
-
51
- with gr.Row():
52
- output = gr.Textbox(label="Converted Amount", interactive=False, elem_id="output_text")
53
-
54
- with gr.Row():
55
- gr.Markdown("""
56
- #### ๐Ÿ’ก Usage Instructions
57
- - **Amount**: Enter the amount you want to convert.
58
- - **From Currency**: Select the currency you want to convert from.
59
- - **To Currency**: Select the currency you want to convert to.
60
-
61
- #### โš ๏ธ Limitations
62
- - The exchange rates may be updated every 15 minutes. Rates might not be real-time.
63
- - Ensure the currency codes are correct, such as `USD` for US Dollar, `EUR` for Euro, etc.
64
- """)
65
-
66
- convert_button.click(fn=convert_currency, inputs=[amount, from_currency, to_currency], outputs=output)
67
-
68
- return interface
69
-
70
- interface = create_interface()
71
- interface.launch(share=True)