eshan6704 commited on
Commit
47f6a53
·
verified ·
1 Parent(s): dc7f773

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +69 -0
app.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import gradio as gr
3
+ from daily import fetch_daily
4
+ from intraday import fetch_intraday
5
+ from info import fetch_info
6
+ from qresult import fetch_qresult
7
+ from result import fetch_result
8
+ from balance import fetch_balance
9
+ from cashflow import fetch_cashflow
10
+ from dividend import fetch_dividend
11
+ from split import fetch_split
12
+ from other import fetch_other
13
+
14
+ # --- Main UI function ---
15
+ def fetch_data(symbol, req_type):
16
+ req_type = req_type.lower()
17
+ if req_type == "daily":
18
+ return fetch_daily(symbol)
19
+ elif req_type == "intraday":
20
+ return fetch_intraday(symbol)
21
+ elif req_type == "info":
22
+ return fetch_info(symbol)
23
+ elif req_type == "qresult":
24
+ return fetch_qresult(symbol)
25
+ elif req_type == "result":
26
+ return fetch_result(symbol)
27
+ elif req_type == "balance":
28
+ return fetch_balance(symbol)
29
+ elif req_type == "cashflow":
30
+ return fetch_cashflow(symbol)
31
+ elif req_type == "dividend":
32
+ return fetch_dividend(symbol)
33
+ elif req_type == "split":
34
+ return fetch_split(symbol)
35
+ elif req_type == "other":
36
+ return fetch_other(symbol)
37
+ else:
38
+ return f"<h1>No handler for {req_type}</h1>"
39
+
40
+ # --- Gradio Interface ---
41
+ iface = gr.Interface(
42
+ fn=fetch_data,
43
+ inputs=[
44
+ gr.Textbox(label="Stock Symbol", value="PNB"),
45
+ gr.Dropdown(
46
+ label="Request Type",
47
+ choices=[
48
+ "info",
49
+ "intraday",
50
+ "daily",
51
+ "qresult",
52
+ "result",
53
+ "balance",
54
+ "cashflow",
55
+ "dividend",
56
+ "split",
57
+ "other"
58
+ ],
59
+ value="info"
60
+ )
61
+ ],
62
+ outputs=gr.HTML(label="Full HTML Output"),
63
+ title="Stock Data API (Full)",
64
+ description="Fetch NSE stock data with charts and indicators",
65
+ api_name="fetch_data"
66
+ )
67
+
68
+ if __name__ == "__main__":
69
+ iface.launch(server_name="0.0.0.0", server_port=7860)