NEXAS commited on
Commit
4e1ef8b
1 Parent(s): e53876b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ import json
4
+
5
+ st.title("Predictive Model App")
6
+
7
+ # Create input fields
8
+ high = st.number_input("High", format="%f")
9
+ low = st.number_input("Low", format="%f")
10
+ open_val = st.number_input("Open", format="%f") # renamed to avoid conflict with the built-in open function
11
+ volume = st.number_input("Volume", format="%f")
12
+
13
+ url = "https://nareshstp.pythonanywhere.com/predict"
14
+
15
+ # Create a button to trigger the prediction
16
+ if st.button("Predict"):
17
+ # Prepare the parameters for the POST request
18
+ params = {
19
+ "high": str(high),
20
+ "low": str(low),
21
+ "open": str(open_val),
22
+ "volume": str(volume)
23
+ }
24
+
25
+ # Make the POST request
26
+ try:
27
+ response = requests.post(url, data=params)
28
+
29
+ # Parse the response and display the result
30
+ if response.status_code == 200:
31
+ result_data = response.json()
32
+ st.write(result_data.get("res"))
33
+ else:
34
+ st.error(f"API Error: {response.status_code}. {response.text}")
35
+
36
+ except Exception as e:
37
+ st.error(f"Error: {e}")
38
+