eshan6704 commited on
Commit
b233a95
·
verified ·
1 Parent(s): 9127b91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -17
app.py CHANGED
@@ -12,6 +12,9 @@ from split import fetch_split
12
  from other import fetch_other
13
  from index import fetch_index
14
 
 
 
 
15
  def fetch_data(mode, req_type, name):
16
  req_type = req_type.lower()
17
  symbol = name
@@ -41,39 +44,47 @@ def fetch_data(mode, req_type, name):
41
  else:
42
  return f"<h1>No handler for {req_type}</h1>"
43
 
 
 
 
44
  with gr.Blocks() as iface:
45
 
46
- # CSS for proper spacing and full textbox visibility
47
  gr.HTML("""
48
  <style>
49
  .gradio-container { padding-top: 0 !important; }
50
- #topblock { margin: 0; padding: 5px; }
 
 
 
 
 
 
51
  #topblock .gr-input, #topblock .gr-select, #topblock .gr-button {
52
  height: 40px !important;
53
  font-size: 16px;
54
  box-sizing: border-box;
55
  }
56
  #topblock .gr-input label, #topblock .gr-select label {
57
- display: none; /* optional: hide labels to save space */
58
  }
59
  </style>
60
  """)
61
 
62
- # Top inputs in a block
63
  with gr.Block(elem_id="topblock"):
64
-
65
- mode_input = gr.Textbox(label="Mode", value="stock", scale=2, placeholder="Mode")
66
- symbol = gr.Textbox(label="Stock symbol", value="PNB", scale=2, placeholder="Symbol")
67
- req_type = gr.Dropdown(
68
- label="req_type",
69
- choices=[
70
- "info","intraday","daily","qresult","result","balance","cashflow",
71
- "dividend","split","index","open","preopen","ce","pe","future","bhav","highlow"
72
- ],
73
- value="info",
74
- scale=3
75
-
76
- btn = gr.Button("Submit", scale=2)
77
 
78
  # Output area
79
  output = gr.HTML()
@@ -81,5 +92,8 @@ with gr.Blocks() as iface:
81
  # Click event
82
  btn.click(fetch_data, inputs=[mode_input, req_type, symbol], outputs=output)
83
 
 
 
 
84
  if __name__ == "__main__":
85
  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
+ # Data fetch function
17
+ # -----------------------------
18
  def fetch_data(mode, req_type, name):
19
  req_type = req_type.lower()
20
  symbol = name
 
44
  else:
45
  return f"<h1>No handler for {req_type}</h1>"
46
 
47
+ # -----------------------------
48
+ # Gradio UI
49
+ # -----------------------------
50
  with gr.Blocks() as iface:
51
 
52
+ # CSS for horizontal top bar, spacing, full visibility
53
  gr.HTML("""
54
  <style>
55
  .gradio-container { padding-top: 0 !important; }
56
+ #topblock {
57
+ margin: 0; padding: 5px;
58
+ display: flex;
59
+ align-items: center;
60
+ gap: 10px;
61
+ flex-wrap: wrap;
62
+ }
63
  #topblock .gr-input, #topblock .gr-select, #topblock .gr-button {
64
  height: 40px !important;
65
  font-size: 16px;
66
  box-sizing: border-box;
67
  }
68
  #topblock .gr-input label, #topblock .gr-select label {
69
+ display: none;
70
  }
71
  </style>
72
  """)
73
 
74
+ # Top inputs in a horizontal block
75
  with gr.Block(elem_id="topblock"):
76
+ mode_input = gr.Textbox(label="Mode", value="stock", scale=2, placeholder="Mode")
77
+ symbol = gr.Textbox(label="Stock symbol", value="PNB", scale=2, placeholder="Symbol")
78
+ req_type = gr.Dropdown(
79
+ label="req_type",
80
+ choices=[
81
+ "info","intraday","daily","qresult","result","balance","cashflow",
82
+ "dividend","split","index","open","preopen","ce","pe","future","bhav","highlow"
83
+ ],
84
+ value="info",
85
+ scale=3
86
+ )
87
+ btn = gr.Button("Submit", scale=2)
 
88
 
89
  # Output area
90
  output = gr.HTML()
 
92
  # Click event
93
  btn.click(fetch_data, inputs=[mode_input, req_type, symbol], outputs=output)
94
 
95
+ # -----------------------------
96
+ # Launch server
97
+ # -----------------------------
98
  if __name__ == "__main__":
99
  iface.launch(server_name="0.0.0.0", server_port=7860)