eshan6704 commited on
Commit
0bb4ac0
·
verified ·
1 Parent(s): 5a966e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -5,7 +5,7 @@ from stock import *
5
 
6
 
7
  # ======================================================
8
- # Scrollable HTML wrapper for all table-based output
9
  # ======================================================
10
  SCROLL_WRAP = """
11
  <div style="
@@ -20,7 +20,6 @@ SCROLL_WRAP = """
20
  </div>
21
  """
22
 
23
-
24
  def wrap(html):
25
  if html is None:
26
  return "<h3>No Data</h3>"
@@ -48,13 +47,13 @@ def update_on_mode(mode):
48
  if mode == "stock":
49
  return (
50
  gr.update(choices=STOCK_REQ, value="info", visible=True),
51
- gr.update(value="ITC") # default stock symbol
52
  )
53
 
54
  elif mode == "index":
55
  return (
56
  gr.update(choices=INDEX_REQ, value="nse_indices", visible=True),
57
- gr.update(value="NIFTY 50") # default index name
58
  )
59
 
60
  return (
@@ -71,7 +70,6 @@ def fetch_data(mode, req_type, name):
71
  symbol = name
72
 
73
  if mode == "index":
74
-
75
  if req_type == "nse_indices":
76
  return wrap(nse_indices())
77
  elif req_type == "nse_open":
@@ -90,7 +88,6 @@ def fetch_data(mode, req_type, name):
90
  return wrap(f"<h3>No handler for {req_type}</h3>")
91
 
92
  elif mode == "stock":
93
-
94
  if req_type == "daily":
95
  return wrap(fetch_daily(symbol))
96
  elif req_type == "intraday":
@@ -126,7 +123,7 @@ with gr.Blocks(title="Stock / Index App") as iface:
126
 
127
  with gr.Row():
128
 
129
- mode_input = gr.SegmentedButton(
130
  ["stock", "index"],
131
  label="Mode",
132
  value="stock",
@@ -135,7 +132,7 @@ with gr.Blocks(title="Stock / Index App") as iface:
135
 
136
  symbol = gr.Textbox(
137
  label="Symbol / Index Name",
138
- value="ITC", # default for stock
139
  placeholder="Enter symbol",
140
  scale=2
141
  )
 
5
 
6
 
7
  # ======================================================
8
+ # Scrollable HTML wrapper for table output
9
  # ======================================================
10
  SCROLL_WRAP = """
11
  <div style="
 
20
  </div>
21
  """
22
 
 
23
  def wrap(html):
24
  if html is None:
25
  return "<h3>No Data</h3>"
 
47
  if mode == "stock":
48
  return (
49
  gr.update(choices=STOCK_REQ, value="info", visible=True),
50
+ gr.update(value="ITC")
51
  )
52
 
53
  elif mode == "index":
54
  return (
55
  gr.update(choices=INDEX_REQ, value="nse_indices", visible=True),
56
+ gr.update(value="NIFTY 50")
57
  )
58
 
59
  return (
 
70
  symbol = name
71
 
72
  if mode == "index":
 
73
  if req_type == "nse_indices":
74
  return wrap(nse_indices())
75
  elif req_type == "nse_open":
 
88
  return wrap(f"<h3>No handler for {req_type}</h3>")
89
 
90
  elif mode == "stock":
 
91
  if req_type == "daily":
92
  return wrap(fetch_daily(symbol))
93
  elif req_type == "intraday":
 
123
 
124
  with gr.Row():
125
 
126
+ mode_input = gr.Radio(
127
  ["stock", "index"],
128
  label="Mode",
129
  value="stock",
 
132
 
133
  symbol = gr.Textbox(
134
  label="Symbol / Index Name",
135
+ value="ITC",
136
  placeholder="Enter symbol",
137
  scale=2
138
  )