Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import joblib
|
| 2 |
from sklearn.preprocessing import StandardScaler
|
| 3 |
-
from flask import Flask,render_template,request
|
| 4 |
import numpy as np
|
| 5 |
import requests
|
| 6 |
|
|
@@ -11,19 +11,26 @@ model=joblib.load('crypto.pkl')
|
|
| 11 |
scaler_x=joblib.load('scaler_x.pkl')
|
| 12 |
|
| 13 |
@app.route('/')
|
| 14 |
-
def home():
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
@app.route('/start')
|
| 29 |
def startt():
|
|
|
|
| 1 |
import joblib
|
| 2 |
from sklearn.preprocessing import StandardScaler
|
| 3 |
+
from flask import Flask,render_template,request, redirect, url_for
|
| 4 |
import numpy as np
|
| 5 |
import requests
|
| 6 |
|
|
|
|
| 11 |
scaler_x=joblib.load('scaler_x.pkl')
|
| 12 |
|
| 13 |
@app.route('/')
|
| 14 |
+
def home():
|
| 15 |
+
print("HOME ROUTE ACCESSED!") # Debug print
|
| 16 |
+
try:
|
| 17 |
+
response = requests.get('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd', timeout=5)
|
| 18 |
+
response.raise_for_status()
|
| 19 |
+
data = response.json()
|
| 20 |
+
btc_price = data['bitcoin']['usd']
|
| 21 |
+
print(f"BTC Price: {btc_price}") # Debug print
|
| 22 |
+
except Exception as e:
|
| 23 |
+
print("Error fetching price:", e)
|
| 24 |
+
btc_price = "Error fetching price"
|
| 25 |
+
|
| 26 |
+
print("Rendering home.html") # Debug print
|
| 27 |
+
return render_template('home.html', btc_price=btc_price)
|
| 28 |
+
|
| 29 |
|
| 30 |
|
| 31 |
+
@app.route('/home')
|
| 32 |
+
def startt():
|
| 33 |
+
return redirect(url_for('home')) # Redirect to the 'home' function
|
| 34 |
|
| 35 |
@app.route('/start')
|
| 36 |
def startt():
|