Spaces:
Paused
Paused
File size: 1,646 Bytes
197bbd2 202f0b2 d21276c 038b05c 4d12675 c027ded dedb25c 197bbd2 2c0f35d 202f0b2 b926175 197bbd2 f949650 d21276c f949650 d21276c f949650 d21276c 5389f31 0d3b3cf 4d12675 d92ecfc 00dc2ef 197bbd2 00dc2ef 197bbd2 2343d41 197bbd2 cc2c9eb 6f95f87 b0d1420 3325363 c28ad05 197bbd2 324d274 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
import joblib
from sklearn.preprocessing import StandardScaler
from flask import Flask,render_template,request, redirect, url_for
import numpy as np
import requests
app=Flask(__name__)
model=joblib.load('crypto.pkl')
scaler_x=joblib.load('scaler_x.pkl')
@app.route('/')
def home():
print("HOME ROUTE ACCESSED!") # Debug print
try:
response = requests.get('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd', timeout=5)
response.raise_for_status()
data = response.json()
btc_price = data['bitcoin']['usd']
print(f"BTC Price: {btc_price}") # Debug print
except Exception as e:
print("Error fetching price:", e)
btc_price = "Error fetching price"
print("Rendering home.html") # Debug print
return render_template('home.html', btc_price=btc_price)
@app.route('/about')
def about():
return render_template('about.html')
@app.route('/canva')
def canva():
return render.template('canva.html')
@app.route('/start')
def startt():
return render_template('index.html')
@app.route('/predict',methods=['POST','GET'])
def pred():
Open=float(request.form.get('open'))
High=float(request.form.get('high'))
Low=float(request.form.get('low'))
Close=float(request.form.get('close'))
Volume=float(request.form.get('volume'))
user_input=[[Open,High,Low,Close,Volume]]
scaled_input=scaler_x.transform(user_input)
prediction=model.predict(scaled_input)
return render_template('index.html',result=prediction[0])
if __name__=='__main__':
app.run(debug=True)
|