-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
29 lines (24 loc) · 696 Bytes
/
app.py
File metadata and controls
29 lines (24 loc) · 696 Bytes
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
from flask import Flask, render_template, jsonify
from dotenv import load_dotenv
import os
from cryptoagent.main import CryptoAgent
import json
from datetime import datetime
app = Flask(__name__)
load_dotenv()
def get_bitcoin_data():
crypto_agent = CryptoAgent(None)
coins = ["btc"]
result = crypto_agent.run_multiple_coins(coins, real_time=True)
data = json.loads(result)[0]['data']
return data
@app.route('/')
def index():
data = get_bitcoin_data()
return render_template('index.html', data=data)
@app.route('/api/bitcoin')
def bitcoin_data():
data = get_bitcoin_data()
return jsonify(data)
if __name__ == '__main__':
app.run(debug=True, port=3000)