I have a chart.js file to show the candlestick graph that I took from tradingview. However, when I tried to load it to the pyhton file using flask, the chart.js somehow cant be loaded.
this is the python file
from flask import Flask, render_template
app = Flask(__name__,
static_folder='./static',
template_folder='./templates')
@app.route("/")
def index():
title = "adsad"
return render_template('index.html', title=title)
if __name__ == "__main__":
app.run(debug=True)
this is the index.html code:
<html>
<head>
<Title>Coinview</Title>
<!-- load the lightweight library from tradingview -->
<script src="https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.production.js"></script>
</head>
<body>
<h2>Coinview</h2>
<!-- load the chart from chart.js -->
<div id='chart'></div>
<div id="trades"></div>
<h3>Settings</h3>
<div id='settings'>
<input type="checkbox" /> RSI
<input type='text' id='rsi_length' name='rsi_length' placeholder="14"/>
Oversold
<int type='text' id='rsi_oversold' name='rsi_oversold' placeholder="30"/>
Overbought
<input type='text' id='rsi_overbought' name='rsi_overbought' placeholder="70"/>
</div>
<!-- CONNECT TO BINANCE DATA STREAM -->
<script>
//var binanceSocket = new WebSocket('wss://stream.binance.com:9443/ws/bnbusdt@trade');
console.log(binanceSocket)
var tradeDiv = document.getElementById('trades')
/*
binanceSocket.onmessage = function (event) {
console.log(event.data);
var messageObject = JSON.parse(event.data)
tradeDiv.append(messageObject.p)
}
*/AbortController
</script>
<script src="chart.js"></script>
<!-- "./static/chart.js" -->
</body>
</html>
For the chart.js script, I just took directly from the trading view library (https://jsfiddle.net/TradingView/eaod9Lq8/).
I wonder where did I do wrong? I already created the static folder and put the chart.js in there, but seems to now working. I also already tried to change this part:
</script>
<script src="chart.js"></script>
to:
</script>
<script src="{{ url_for('static', filename='style.css') }}"></script>
but seems to not working also