Hello everyone,
Im building a Flask website and im trying to receive data using the modulo yfinance from yahoo finance.
In my localhost works perfectly, i upload the code as well but i dont think the problem is there.
I did some test like returning text and it works, thats why i dont think is the code, im thinking it has do something with the firewall or the web is not allowed to search outside in the web, i have been looking around and doing tons of things with firewalls etc, i would appreciate any help on this.
Thanks!
@app.route('/market_overview')
@login_required
def ibex35_graph():
try:
ibex35_ticker = '^IBEX'
ibex35_data = yf.download(ibex35_ticker, period='1y')
# Creating the interactive Plotly graph
fig = go.Figure()
fig.add_trace(go.Scatter(x=ibex35_data.index, y=ibex35_data['Close'], mode='lines', name='IBEX35'))
fig.update_layout(title='IBEX35 Index', xaxis_title='Date', yaxis_title='Price')
# Converting the graph to HTML
graph_html = pio.to_html(fig, full_html=False)
# Rendering the template with the graph
return render_template('marketOverview.html', graph_html=graph_html)
except Exception as e:
# Handle the exception and return an error message
error_message = f"An error occurred: {str(e)}"
return render_template('error.html', error_message=error_message)