Skip to content

Commit da84ed3

Browse files
authored
initial commit
1 parent 7875a4b commit da84ed3

File tree

6 files changed

+172
-0
lines changed

6 files changed

+172
-0
lines changed

falsk_bitcoin_api/BitcoinAPI.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import requests
2+
class Bitcoin:
3+
4+
API_URL = 'https://api.coindesk.com/v1/bpi/currentprice.json'
5+
def __init__(self):
6+
pass
7+
#self.Currency = Currency
8+
@classmethod
9+
def read_api(cls):
10+
resonse = requests.get(Bitcoin.API_URL)
11+
return resonse
12+
13+
@classmethod
14+
def parse_responce(cls):
15+
json_responce = Bitcoin.read_api()
16+
respose_list = []
17+
if json_responce.status_code == 200:
18+
r_json = json_responce.json()
19+
return r_json
20+
21+
22+
23+
24+
25+
923 Bytes
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from flask import Flask, render_template, request
2+
import requests
3+
from BitcoinAPI import Bitcoin
4+
5+
6+
7+
app = Flask(__name__)
8+
@app.route('/')
9+
@app.route('/home')
10+
def home():
11+
12+
bitcoin = Bitcoin.parse_responce()
13+
print(type(bitcoin))
14+
#currency = json.loads(str(bitcoin_json))
15+
# print(type(currency))
16+
17+
18+
#print(response_list)
19+
return render_template("homepage.html", tree=bitcoin)
20+
21+
22+
if __name__ == '__main__':
23+
app.run(debug=True)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
html,
2+
body {
3+
height: 100%;
4+
}
5+
6+
.container{
7+
width:800px;
8+
margin: 10px auto;
9+
padding: 10px;
10+
}
11+
12+
.child {
13+
float: left;
14+
width: 348px;
15+
height: 166px;
16+
border: 1px dashed #ccc;
17+
margin-right: 50px;
18+
background: #f9f9f9;
19+
background: -moz-linear-gradient(top, rgba(248,248,248,1) 0%, rgba(249,249,249,1) 100%);
20+
background: -webkit-linear-gradient(top, rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);
21+
background: -o-linear-gradient(top, rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);
22+
background: -ms-linear-gradient(top, rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);
23+
background: linear-gradient(top, rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);
24+
25+
}
26+
h1, h2{
27+
text-align:center;
28+
color:green;
29+
font-style:normal;
30+
letter-spacing: 10px;
31+
32+
}
33+
34+
.time{
35+
background-color: white;
36+
font: icon;
37+
font-variant: all-small-caps;
38+
color: firebrick;
39+
font-size: large;
40+
padding-left: 21px;
41+
42+
}
43+
44+
.heading {
45+
position: relative;
46+
display: inline-block;
47+
width: 100%;
48+
line-height: 2em;
49+
background-color: #3F89A5;
50+
font-weight: normal;
51+
color: white;
52+
text-indent: 0.5em;
53+
font-weight: bold;
54+
55+
}
56+
57+
.list-style {
58+
list-style-image: url('imgs/arrow-left.png');
59+
text-align: justify;
60+
padding-left: 20px;
61+
text-transform: capitalize;
62+
}
63+
.info {
64+
width:800px;
65+
height: 300px;
66+
border: 1px dashed #ccc;
67+
margin: 20px;
68+
background: #f9f9f9;
69+
background: -moz-linear-gradient(top, rgba(248,248,248,1) 0%, rgba(249,249,249,1) 100%);
70+
background: -webkit-linear-gradient(top, rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);
71+
background: -o-linear-gradient(top, rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);
72+
background: -ms-linear-gradient(top, rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);
73+
background: linear-gradient(top, rgba(248,248,248,1) 0%,rgba(249,249,249,1) 100%);
74+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>{{pagetitle}}</title>
8+
<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
9+
{% if custom_css %}
10+
<link rel="stylesheet" href="{{ url_for('static', filename='css/'+ custom_css +'.css') }}">
11+
12+
{% endif %}
13+
14+
</head>
15+
16+
<body>
17+
{% block body %}
18+
19+
{% endblock %}
20+
</body>
21+
22+
</html>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{% extends 'base.html' %}
2+
{% block body %}
3+
<div class="container" >
4+
<h1>Bitcoin Price</h1>
5+
<p class="time">Time Updated: {{tree['time']['updated']}} </p>
6+
7+
{% for key,value in tree['bpi'].items() recursive %}
8+
<div class="info">
9+
<h3 class="heading">
10+
Bitcoin Price details in :{{ key }}
11+
</h3>
12+
<h4 >
13+
14+
{% for key, val in value.items() recursive %}
15+
{% if key != "symbol" %}
16+
<p class="list-style">
17+
{{key}} : {{val}}
18+
</p>
19+
{% endif %}
20+
{% endfor%}
21+
22+
</h4>
23+
</div>
24+
{% endfor%}
25+
26+
</div>
27+
{% endblock %}
28+

0 commit comments

Comments
 (0)