-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.html
101 lines (83 loc) · 2.75 KB
/
index.html
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.8.8/brython.js" integrity="sha256-rA89wPrTJJQFWJaZveKW8jpdmC3t5F9rRkPyBjz8G04=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.8.8/brython_stdlib.js" integrity="sha256-Gnrw9tIjrsXcZSCh/wos5Jrpn0bNVNFJuNJI9d71TDs=" crossorigin="anonymous"></script>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 25px;
padding: 30px;
line-height: 1.6;
background-image: url('./background.png');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
}
h1 {
text-align: center;
margin-bottom: 30px;
border-bottom: 1px #ccc solid;
}
h2 {
margin-top: 20px;
}
button {
cursor: pointer;
display: block;
background: #333;
color: #fff;
border: 0;
border-radius: 5px;
padding: 10px 20px;
margin: 20px 0;
}
input[type="text"] {
border: 1px #ccc solid;
width: 300px;
padding: 4px;
height: 35px;
margin-top: 20px;
}
.card {
margin: 20px 0;
border: #ccc 1px solid;
padding: 20px;
}
</style>
<title>Songs Lyrics</title>
</head>
<body onload="brython()">
<h1>Get Songs Lyrics</h1>
<input type="text" id="artist-input" placeholder="Enter something">
<button id="lyrics-btn">Get Lyrics</button>
<div id="lyrics" class="card">Click the "get lyrics" button</div>
<!-- Ajax call -->
<script type="text/python" id="script3">
import json
from browser import document, ajax
def on_complete(req):
data = json.loads(req.responseText)
lyrics = data['lyrics']
document['lyrics'].text = lyrics
def get_lyrics(e):
req = ajax.ajax()
input_data = document['artist-input'].value.split()
artist = input_data[0]
title = ' '.join(input_data[1:])
url = f'https://api.lyrics.ovh/v1/{artist}/{title}'
req.open('GET', url, True)
req.bind('complete', on_complete)
document['lyrics'].text = 'Loading...'
req.send()
document['lyrics-btn'].bind('click', get_lyrics)
</script>
</body>
</html>