-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbase_index.html
79 lines (66 loc) · 3.05 KB
/
base_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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Currency converter</title>
<!-- Pyscript -->
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<!--<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />-->
<!-- bootstrap for styling , Pyscript can also be used for styling instead of bootstrap -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous" />
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<!-- roboto font -->
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap" rel="stylesheet">
<style>
body {
font-family:roboto;
background-color: #fcfcfc;
padding-top: 55px;
min-height: 100vh;
margin:0;
display:flex;
flex-direction:column;
}
</style>
</head>
<body>
<!-- write your Python code in py-script tag -->
<py-script>
from js import document,alert
def euro_converter(value):
return f'{int(value) / 1.95:.2f}'
def pound_converter(value):
return f'{int(value) / 2.30:.2f}'
def run(*ags, **kws):
# get currency value
currency_value = document.getElementById('currency_value').value;
# convert BGN value to a EUR value
euro = euro_converter(currency_value)
# convert BGN value to a GBP value
pound = pound_converter(currency_value)
pyscript.write("euro_currency", euro)
pyscript.write("pound_currency", pound)
</py-script>
<div class="container">
<h1 class="text-center">
Currency Converter
<small class="text-muted">With <a href="https://pyscript.net/" target="_blank"><b>Pyscript</b></a></small>
</h1>
<br />
<p>
<h4>BGN Leva currency:</h4>
<input id="currency_value" type="text" class="form-control" aria-label="Large" aria-describedby="inputGroup-sizing-sm" placeholder="Enter BNG leva" /></p>
<button id="convert" type="submit" class="btn btn-primary" pys-onClick="run">Convert currency</button>
<p>
<h4>Euro currency:</h4>
<textarea id="euro_currency" class="form-control" rows="2" aria-label="Large" aria-describedby="inputGroup-sizing-sm" placeholder="Euro currency"></textarea>
</p>
<h4>Pound currency:</h4>
<textarea id="pound_currency" class="form-control" rows="2" aria-label="Large" aria-describedby="inputGroup-sizing-sm" placeholder="Pound currency"></textarea>
</p>
</div>
</body>
</html>