Download server/api.py from tmmdev2/llama-vision-charts: direct link, hf CLI and curl.
- Browser
- Download file 907 Bytes
-
https://huggingface.co/tmmdev2/llama-vision-charts/resolve/6bc470863fb182e458f376beea2e6ff8ea95fe4e/server/api.py
- Command line
-
hf download hf://tmmdev2/llama-vision-charts@6bc470863fb182e458f376beea2e6ff8ea95fe4e/server/api.py
-
curl -L -o api.py https://huggingface.co/tmmdev2/llama-vision-charts/resolve/6bc470863fb182e458f376beea2e6ff8ea95fe4e/server/api.py
907 Bytes
| from flask import Flask, jsonify | |
| from flask_cors import CORS | |
| import yfinance as yf | |
| app = Flask(__name__) | |
| CORS(app) | |
| def fetch_candles(): | |
| try: | |
| ticker = yf.Ticker('AAPL') | |
| data = ticker.history(period='1y') | |
| candles = [] | |
| for index, row in data.iterrows(): | |
| candle = { | |
| 'time': int(index.timestamp() * 1000), | |
| 'open': float(row['Open']), | |
| 'high': float(row['High']), | |
| 'low': float(row['Low']), | |
| 'close': float(row['Close']), | |
| 'volume': float(row['Volume']) | |
| } | |
| candles.append(candle) | |
| return jsonify(candles) | |
| except Exception as e: | |
| return jsonify({'error': str(e)}), 500 | |
| if __name__ == '__main__': | |
| app.run(debug=True, port=5000) | |