eshan6704 commited on
Commit
bc71b9f
·
verified ·
1 Parent(s): 984b382

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -13
app.py CHANGED
@@ -12,6 +12,7 @@ from split import fetch_split
12
  from other import fetch_other
13
  from index import fetch_index
14
 
 
15
  # -----------------------------
16
  # Data fetch function
17
  # -----------------------------
@@ -44,33 +45,50 @@ def fetch_data(mode, req_type, name):
44
  else:
45
  return f"<h1>No handler for {req_type}</h1>"
46
 
 
47
  # -----------------------------
48
- # Gradio UI (default styling)
49
  # -----------------------------
50
- with gr.Blocks() as iface:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
- # Top inputs
53
- with gr.Blocks():
54
- mode_input = gr.Textbox(label="Mode", value="stock", placeholder="Mode")
55
- symbol = gr.Textbox(label="Stock symbol", value="PNB", placeholder="Symbol")
56
  req_type = gr.Dropdown(
57
- label="req_type",
58
  choices=[
59
  "info","intraday","daily","qresult","result","balance","cashflow",
60
  "dividend","split","index","open","preopen","ce","pe","future","bhav","highlow"
61
  ],
62
- value="info"
 
63
  )
64
- btn = gr.Button("Submit")
65
 
66
- # Output area
67
- output = gr.HTML()
 
 
68
 
69
- # Click event
70
  btn.click(fetch_data, inputs=[mode_input, req_type, symbol], outputs=output)
71
 
 
72
  # -----------------------------
73
- # Launch server
74
  # -----------------------------
75
  if __name__ == "__main__":
76
  iface.launch(server_name="0.0.0.0", server_port=7860)
 
12
  from other import fetch_other
13
  from index import fetch_index
14
 
15
+
16
  # -----------------------------
17
  # Data fetch function
18
  # -----------------------------
 
45
  else:
46
  return f"<h1>No handler for {req_type}</h1>"
47
 
48
+
49
  # -----------------------------
50
+ # UI
51
  # -----------------------------
52
+ with gr.Blocks(title="Stock / Index App") as iface:
53
+
54
+ gr.Markdown("### **Stock / Index Data Fetcher**")
55
+
56
+ # ----- Top bar -----
57
+ with gr.Row():
58
+ mode_input = gr.Textbox(
59
+ label="Mode",
60
+ value="stock",
61
+ placeholder="stock / index",
62
+ scale=1
63
+ )
64
+
65
+ symbol = gr.Textbox(
66
+ label="Symbol / Index Name",
67
+ value="PNB",
68
+ placeholder="Enter symbol",
69
+ scale=2
70
+ )
71
 
 
 
 
 
72
  req_type = gr.Dropdown(
73
+ label="Request Type",
74
  choices=[
75
  "info","intraday","daily","qresult","result","balance","cashflow",
76
  "dividend","split","index","open","preopen","ce","pe","future","bhav","highlow"
77
  ],
78
+ value="info",
79
+ scale=2
80
  )
 
81
 
82
+ btn = gr.Button("Fetch", scale=1)
83
+
84
+ # ----- Output -----
85
+ output = gr.HTML(label="Output")
86
 
 
87
  btn.click(fetch_data, inputs=[mode_input, req_type, symbol], outputs=output)
88
 
89
+
90
  # -----------------------------
91
+ # Launch
92
  # -----------------------------
93
  if __name__ == "__main__":
94
  iface.launch(server_name="0.0.0.0", server_port=7860)