## Vaja ESP32
### Vaja 1 - Vrtenje vsake 4. ledice

##### [Dodatno](https://hackmd.io/@lukac/zapiski)
```python=
import neopixel
from machine import Pin
from utime import sleep
num_leds = 16
leds = neopixel.NeoPixel(Pin(5),num_leds)
def someOff():
for l in range(num_leds):
leds[l] = [0,0,0]
leds.write
off= num_leds//4
while True:
for i in range(num_leds):
leds[i] = [37,150,190]
leds[(i+off) % num_leds] = [37,150,190]
leds[(i+off*2) % num_leds] = [37,150,190]
leds[(i+off*3) % num_leds] = [37,150,190]
leds.write()
sleep(0.5)
someOff()
```
### Vaja 2 - Reguliranje RGB z Potenciometrom
```python=
from machine import Pin, ADC
from utime import sleep
import neopixel
num_leds = 16
potRed = 32
potGreen = 33
potBlue = 25
leds = neopixel.NeoPixel(Pin(4),num_leds)
p1 = ADC(Pin(potRed))
p2 = ADC(Pin(potGreen))
p3 = ADC(Pin(potBlue))
while True:
leds.fill([p1.read()//16,p2.read()//16,p3.read()//16])
leds.write()
```

### Vaja 3 - Gumb in LED
```python=
from machine import Pin
led = Pin(19,Pin.OUT)
led2 = Pin(21, Pin.OUT)
btn = Pin(5, Pin.IN, Pin.PULL_UP)
btn2 = Pin(18, Pin.IN, Pin.PULL_UP)
while True:
g = not bool(btn.value())
g2 = not bool(btn2.value())
if g:
led.value(1)
elif g2:
led.value(1)
led2.value(1)
else:
led.value(0)
led2.value(0)
```

### Vaja 4 - hitrost animacije
```python=
from machine import Pin, ADC
import neopixel
from utime import sleep
num_leds = 16
pot = 32
leds = neopixel.NeoPixel(Pin(2),num_leds)
p1 = ADC(Pin(pot))
while True:
for i in range(num_leds):
leds[i] = (14,255,0)
leds.write()
sleep(p1.read()*0.001)
leds[i] = (0,0,0)
leds.write()
```

### Vaja 5 - Animacija

```python=
from machine import Pin
import neopixel
from utime import sleep
import random as rng
num_leds = 22
leds = neopixel.NeoPixel(Pin(2),num_leds)
while True:
col = [rng.randrange(255),rng.randrange(255),rng.randrange(255)]
for i in range(num_leds):
leds[i] = col
leds.write()
sleep(0.1)
leds[i] = [0,0,0]
if i == num_leds-1:
leds[i] = col
leds.write()
num_leds-= 1
```
### Vaja 6 - Lov Ledic

```python=
from machine import Pin, ADC
import neopixel
from utime import sleep, time
import random as rng
num_leds=50
leds = neopixel.NeoPixel(Pin(2),num_leds)
p1 = ADC(Pin(32))
score = 0
y = int(round(p1.read()/83.57142857142857,0))
noRounds = int(input("Number of rounds: "))
for i in range(noRounds):
x = rng.randint(0,49)
t = time()
print("No.",i+1)
while y != x:
y = int(round(p1.read()/83.57142857142857,0))
leds[y] = [0,255,0]
leds[x] = [255,0,0]
leds.write()
leds[y] = [0,0,0]
sleep(1)
leds[x] = [0,0,0]
leds.write()
if i+1 == noRounds:
print("Youre score is:",score, "\nTime:",t,"s")
break
else:
score += 1
```
### Vaja 7 - barve wokwi
```python=
from time import sleep, time
from machine import Pin
from neopixel import NeoPixel
numLeds = 16
btn = Pin(5, Pin.IN, Pin.PULL_UP)
leds= NeoPixel(Pin(4), numLeds)
green = (0, 255, 0)
blue = (0,0,255)
red = (255,0,0)
i = 0
def timer():
while True:
if bool(btn.value()) == True:
s = 0
sleep(1)
s+=1
else:
return s
while True:
sleep(1)
t = time()
x = bool(btn.value())
if x == False:
if timer() < 1:
leds[i] = (0,255,0)
leds.write()
i+=1
elif 1<timer()<2:
leds[i] = (0,0,255)
leds.write()
i+=1
else:
leds[i] = (255,0,0)
leds.write()
i+=1
```
### Vaja 8 - Fells like
```python=
import dht
from machine import Pin, ADC
import math
from utime import sleep
d = dht.DHT11(Pin(2))
p = ADC(Pin(32))
while True:
temp = d.temperature()
vla = d.humidity()
x = int(p.read()/40.95)
print(temp+0.5*(1-(vla/100))- 0.2*math.sqrt(x))
sleep(3)
```
### vaja 9
```python=
from machine import Pin , PWM
from utime import sleep
import random as rng
LedI = Pin(0,Pin.OUT)
LedII = Pin(16,Pin.OUT)
LedIII = Pin(2,Pin.OUT)
LedIV = Pin(4,Pin.OUT)
LedV = Pin(17,Pin.OUT)
LedVI = Pin(5,Pin.OUT)
LedVII = Pin(18,Pin.OUT)
btn = Pin(15, Pin.IN, Pin.PULL_UP)
while True:
g = not bool(btn.value())
if g:
r = rng.randint(1,6)
if r == 1:
LedI.value(1)
sleep(2)
LedI.value(0)
if r == 2:
LedII.value(1)
LedVII.value(1)
sleep(2)
LedII.value(0)
LedVII.value(0)
if r == 3:
LedIV.value(1)
LedI.value(1)
LedVI.value(1)
sleep(2)
LedIV.value(0)
LedI.value(0)
LedVI.value(0)
if r == 4:
LedII.value(1)
LedVII.value(1)
LedIII.value(1)
LedV.value(1)
sleep(2)
LedII.value(0)
LedVII.value(0)
LedIII.value(0)
LedV.value(0)
if r == 5:
LedI.value(1)
LedII.value(1)
LedVII.value(1)
LedV.value(1)
LedIII.value(1)
sleep(2)
LedI.value(0)
LedII.value(0)
LedVII.value(0)
LedV.value(0)
LedIII.value(0)
if r == 6:
LedIII.value(1)
LedII.value(1)
LedIV.value(1)
LedV.value(1)
LedVI.value(1)
LedVII.value(1)
sleep(2)
LedIII.value(0)
LedII.value(0)
LedIV.value(0)
LedV.value(0)
LedVI.value(0)
LedVII.value(0)
```

### Vaja 10 - ugibanje barv
```python=
from machine import Pin, ADC
import neopixel
import random as rng
r=ADC(Pin(34))
g= ADC(Pin(35))
b= ADC(Pin(32))
num_leds = 16
leds = neopixel.NeoPixel(Pin(4),num_leds)
ledsG = neopixel.NeoPixel(Pin(2),num_leds)
btn = Pin(16, Pin.IN, Pin.PULL_UP)
def convert(x, in_min, in_max, out_min, out_max):
return (x - in_min) * (out_max - out_min) // (in_max - in_min) + out_min
for i in range(num_leds):
col = [rng.randrange(255),rng.randrange(255),rng.randrange(255)]
leds.fill(col)
leds.write()
while btn.value() == 1:
rg = convert(r.read(), 0, 4095, 1, 255)#round(r.read()/16.05882352941176,0)
gg = convert(g.read(), 0, 4095, 1, 255)#round(g.read()/16.05882352941176,0)
bg = convert(b.read(), 0, 4095, 1, 255)#round(b.read()/16.05882352941176,0)
ledsG.fill([int(rg),int(gg),int(bg)])
ledsG.write()
if btn.value() == 0:
s = [rg,gg,bg]
break
print("Red: ",col[0]-s[0])
print("Green: ",col[1]-s[1])
print("Blue: ",col[2]-s[2])
i = str(input("New? :"))
if i == "y":
pass
else:
break
```

### h3
```python=
from machine import Pin, ADC
import neopixel
import random as rng
from utime import sleep, time
num = 50
last = 0
q = 0
p = ADC(Pin(34))
leds = neopixel.NeoPixel(Pin(0),num)
def convert(x, in_min, in_max, out_min, out_max):
return (x - in_min) * (out_max - out_min) // (in_max - in_min) + out_min
x = convert(p.read(),0,4095,0,49)
while q < 5:
z = rng.randrange(0,49)
t = time()
if (last - z) > 20 or (last + z) > 20:
last = z
while x != z:
x = convert(p.read(),0,4095,0,49)
leds[x] = [255,0,0]
leds[z] = [0,255,0]
leds.write()
leds[x] = [0,0,0]
leds.write()
leds[x] = [255,0,0]
leds[z] = [0,255,0]
leds.write()
sleep(0.5)
leds.fill([0,0,0])
leds.write()
q += 1
print("Time: ",t)
```

## API začetki
### Klicanje spletne strani
```python=
import requests
url = "https://wokwi.com/micropython"
call = requests.get(url)
print(call.text)
```
### Izpis iz dictionary
```python=
import requests
from pprint import pprint
dict = {"Ime" : "David",
"Starost" : "17",
"Zaposlen" : False,
"Siblings" : ["Matej"]}
url = "https://api.chucknorris.io/jokes/random"
call = requests.get(url)
pprint(dict["Ime"])
pprint(dict["Zaposlen"])
pprint(dict["Siblings"][0])
pprint(dict.get("Ime", -1))
pprint(dict.get("Ime2", -1))
```
### URL
```python=
import requests
from pprint import pprint
dict = {"Ime" : "David",
"Starost" : "17",
"Zaposlen" : False,
"Siblings" : ["Matej"]}
url = "https://deckofcardsapi.com/api/deck/new/shuffle/?deck_count=1"
call = requests.get(url).json()
pprint(call)
```
### Vaja 1 - API Open Weather Map
```python=
import requests
from pprint import pprint
apiKey = "b60c073e506a66cd318d5d990dc939fe"
payload = {"lon":"14.312596353103178",
"lat":"46.274773772162945",
"appid":apiKey}
baseURL = "https://api.openweathermap.org/data/2.5/weather"
call = requests.get(baseURL, params = payload).json()
pprint(call)
```
### Vaja 2
```python=
import requests
from pprint import pprint
apiKey = "b60c073e506a66cd318d5d990dc939fe"
#40.711708415949175, -74.01290114709457
def get_weather(lat,lon):
dict = {"lat":lat,
"lon" : lon,
"units": "metric",
"lang" : "sl",
"appid": apiKey
}
baseURL = "https://api.openweathermap.org/data/2.5/weather"
call = requests.get(baseURL, params=dict).json()
return call["main"]["feels_like"]
#pprint(js)
#pprint(js["weather"][0]["description"])
sezMest = [["Laško",46.15508266288024, 15.237139533976794],["Ajdovščina", 45.88804030068664, 13.915667092866444 ],["Komenda", 46.20541364651428, 14.54073627696203],["Trstenik", 46.317587005307075, 14.372544633883736],["Kranjska gora", 46.485365629436224, 13.783885731258243],["Zgornje Duplje", 46.30661438523437, 14.29512093441640646]]
temp = []
for s in sezMest:
t = get_weather(s[1],s[2])
temp.append([s[0],t])
def getTemp(item):
return item[1]
temp.sort(key=getTemp)
pprint(temp)
```
### Vaja 3
```python=
import requests
from pprint import pprint
url = 'http://www.smsapi.si/poslji-sms'
payload = {"un":"twin_towers",
"ps":"17cd9c733edfa5e572605379026a9e1b4df8f734dd",
"from": "031480333",
"to": "041608528",
"m": "Glory, glory, Man United Glory, glory, Man United Glory, glory, Man Unite As The Reds Go Marching On On On",
"cc": "386"
}
k = requests.get(url,params=payload)
print(k.text)
```
### Vaja4 - Number facts
```python=
import requests
for i in range(101):
url = f"http://numbersapi.com/{i}/trivia"
print(url)
k = requests.get(url)
print(k.text)
```
### vaja 5 - spooncalculator
```python=
import requests
from pprint import pprint
url = "https://api.spoonacular.com/recipes/random?"
urlMP = "https://api.spoonacular.com/mealplanner/generate"
urlAutoCompl = "https://api.spoonacular.com/food/ingredients/autocomplete"
urlMAouto = "https://api.spoonacular.com/recipes/autocomplete"
urlConv = "https://api.spoonacular.com/recipes/convert"
urlMenu = "https://api.spoonacular.com/food/menuItems/search"
urlWine = "https://api.spoonacular.com/food/wine/pairing"
urlFind = "https://api.spoonacular.com/recipes/findByIngredients"
eng = []
while True:
i = input()
if i == "":
break
eng.append(i)
eng = ",".join(eng)
payload = {
"ingredients" : eng,
"number" : "10",
"limitLicense" : True,
"ranking" : 1,
"apiKey" : "55b99fd4f754441b9df11cb1e76e059c"
}
j = requests.get(urlFind,params=payload).json()
pprint(j)
```
### Vaja 5 - pokeapi
```python=
import requests
from pprint import pprint
url = "https://pokeapi.co/api/v2/pokemon/rayquaza"
call = requests.get(url).json()
for i in call["moves"]:
print(i["move"]["name"])
```
### Vaja 6 - Bored API
```python=
import requests
from pprint import pprint
# st. ljudi, cena, št aktivnosti
url = "https://www.boredapi.com/api/activity/"
st = int(input("Number of people: "))
num = int(input("Number of activities: "))
price = int(input(("Price: ")))
s = []
payload = {
"participants": st,
"minprice" : 0,
"maxprice" : price,
#"price": 0
}
#call = requests.get(url, params=payload).json()
for k in range(num):
call = requests.get(url, params=payload).json()
pprint(call["activity"])
```
# Flask
``` python=
import requests
from flask import Flask, render_template
import random
app = Flask("app")
@app.route('/')
def index():
k = requests.get("https://zenquotes.io/api/quotes/author/babe-ruth/").json()
temp = k[0]['q']
return render_template("index.html",quote=temp)
app.run(host='0.0.0.0', port=8080, debug=True)
```
### Vaja 2
```python=
import requests
from flask import Flask, render_template
app = Flask("app")
d = requests.get("https://dog.ceo/api/breeds/list/all").json()
sez = list(d["message"].keys())
print(sez)
@app.route('/')
def index():
d = requests.get("https://dog.ceo/api/breeds/list/all").json()
sez = list(d["message"].keys())
return render_template("index.html",sez=sez)
app.run(host='0.0.0.0', port=8080, debug=True)
```
```htmlmixed=
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello Bulma!</title>
</head>
<body>
Pasme:
{%for s in sez%}
<ul><li>{{ s }}</li></ul>
{% endfor %}
</table>
</body>
</html>
```
### Vaja 3
```python=
import requests
from flask import Flask, render_template
from pprint import pprint
app = Flask("app")
@app.route('/')
def index():
Ingridients = []
mesurment = []
sk = []
f = requests.get("https://www.themealdb.com/api/json/v1/1/random.php").json()
Name = f["meals"][0]["strMeal"]
for i in range(1,21):
if f["meals"][0][f"strIngredient{i}"]:
Ingridients.append(f["meals"][0][f"strIngredient{i}"])
mesurment.append(f["meals"][0][f"strMeasure{i}"])
print(mesurment,Ingridients)
Instructions = f["meals"][0]["strInstructions"]
Image = f["meals"][0]["strMealThumb"]
return render_template("index.html",name=Name,stvari=Instructions,img=Image,ing=Ingridients,meas=mesurment)
app.run(host='0.0.0.0', port=8080, debug=True)
```
```htmlembedded=
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>doc</title>
</head>
<body>
<h2>{{ name }}</h2>
<table>
<tr>
<th><b>Ingridients</b></th>
<th><b>Mesurment</b></th>
</tr>
{% for i in range(len(ing))}
<tr>
<td>{{ ing[i] }}</td>
<td>{{ meas[i] }}</td>
</tr>
{% endfor%}
</table>
<table>
<tr>
<td><img src={{img}} width="300" height="300"></td>
<td><p><b>Instructions</b> <br>{{ stvari }}</p></td>
</tr>
</table>
</body>
</html>
```
### Vaja 4

```python=
from flask import Flask, render_template, request
from pprint import pprint
import random
app = Flask("app")
@app.route('/')
def index():
return render_template("index.html")
@app.route('/izracunaj')
def izracunaj():
d = request.args
prvi = d.get("first", "Janez")
drugi = d.get("second", "Lojzka")
rnd = random.randint(0,100)
return render_template("rezultati.html",uno=prvi,dos=drugi,r=rnd)
app.run(host='0.0.0.0', port=8080, debug=True)
```
```htmlembedded=
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Doc</title>
</head>
<body>
<form action="/izracunaj">
<label>Name numero uno:</label><br>
<input type="text" name="first"><br>
<label>Name numero dos:</label><br>
<input type="text" name="second"><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
```
```htmlembedded=
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Doc</title>
</head>
<body>
<h2>IZRAČUN</h2>
<p>
{{uno}} + {{dos}} = {{r}} %
</p>
</body>
</html>
```
### vaja 5
```python=
import requests
from flask import Flask, render_template
x = []
app = Flask("app")
@app.route('/')
def index():
pf = requests.get('https://api.agify.io?name=david').json()
dlf = requests.get('https://api.genderize.io?name=david').json()
af = requests.get('https://api.nationalize.io/?name=david').json()
f9 = af["country"]
for country_id in f9:
x.append(country_id['country_id'])
age = pf["age"]
sp = dlf["gender"]
m = dlf["probability"]
n = pf["name"]
return render_template('index.html', age = age, spol = sp, moznost = m, x = x,name = n)
app.run(host='0.0.0.0', port=8080, debug=True)
```
```html=
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>doc</title>
</head>
<body>
<p>
{{ name }}
</p>
<table>
<tr>
<th> Spol </th>
<th> Verjtnost </th>
</tr>
<tr>
<td>{{spol}}</td>
<td>{{moznost}}</td>
</tr>
</table>
<h3>Drzave</h3>
<p>
{{x}}
</p>
```
### vaja 6
```htmlembedded=
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Doc</title>
<style>
body{
margin:20px;
background-color:#537d99;
}
h1{
font-family: "Times New Roman", Times, serif;
color:#d69074;
text-align:center;
}
p{
font-family: "Times New Roman", Times, serif;
color:#edc593;
font-size:1.2em;
padding:5px;
}
</style>
</head>
<body>
<h1>Deus dê</h1>
<p>IP:
{{ ip }}
</p>
<p>Lan:
{{ lat }}
</p>
<p>Lon:
{{lon}}
</p>
<p>
Country: {{ ß }}, {{ Ł }}
</p>
<p>
Weather: {{ ł }}
</p>
<img src="https://openweathermap.org/img/wn/{{ š }}.png" alt ='sljejka' height='170' width='200'>
</body>
</html>
```
```python=
from flask import Flask, render_template, request
import requests
from pprint import pprint
app = Flask("app")
@app.route('/')
def index():
API_KEY = "420c89673fa140bf927be5752ab5c9c5"
APIkey = "c7244d9045470736bf3e1e55e2f57235"
x = dict(request.headers)
x = x["X-Forwarded-For"].split(",")[0]
url = f"https://api.ipgeolocation.io/ipgeo?apiKey={API_KEY}&ip={x}"
q = requests.get(url).json()
lat = q["latitude"]
lon = q["longitude"]
Ł =q["country_name"]
urlmk2 = f"https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={APIkey}"
đ = requests.get(urlmk2).json()
ł = đ["weather"][0]["main"]
ß = đ["sys"]["country"]
š = đ["weather"][0]["icon"]
pprint(đ)
return render_template("index.html",lat = lat, lon = lon,ip = x, Ł = Ł, ł=ł,ß=ß,š=š)
app.run(host='0.0.0.0', port=8080, debug=True)
```
### vaja 7
```python=
from flask import Flask,render_template,request
import random
import requests
import datetime
app = Flask('app')
@app.route('/')
def hello_world():
return render_template("index.html")
@app.route("/coinflip")
def coinflip():
return render_template("coinflip.html")
@app.route("/rndnum")
def rndnum():
return render_template("randomnumber.html")
@app.route("/theword")
def word():
return render_template("word.html")
@app.route("/dice")
def maindice():
return render_template("dice.html")
@app.route('/coinflipper')
def coinflipper():
heads = {"img":"https://i.postimg.cc/CBNJNfDJ/head.png","rez":"Heads" }
tails = {"img":"https://i.postimg.cc/zysdXN8w/tail.png","rez":"Tails" }
f = random.randint(0,1)
if f == 0:
return heads
else:
return tails
@app.route("/randomquote")
def randomQuote():
quotes = ["The greatest glory in living lies not in never falling, but in rising every time we fall. -Nelson Mandela","The way to get started is to quit talking and begin doing. -Walt Disney","Your time is limited, so don't waste it living someone else's life. Don't be trapped by dogma – which is living with the results of other people's thinking. -Steve Jobs","If life were predictable it would cease to be life, and be without flavor. -Eleanor Roosevelt","If you look at what you have in life, you'll always have more. If you look at what you don't have in life, you'll never have enough. -Oprah Winfrey","If you set your goals ridiculously high and it's a failure, you will fail above everyone else's success. -James Cameron","Life is what happens when you're busy making other plans. -John Lennon","Spread love everywhere you go. Let no one ever come to you without leaving happier. -Mother Teresa","When you reach the end of your rope, tie a knot in it and hang on. -Franklin","Always remember that you are absolutely unique. Just like everyone else. -Margaret Mead","I have a dream that one day this nation will rise up and live out the true meaning of its creed: “We hold these truths to be self-evident, that all men are created equal.” -Martin Luther King JR","When we stop counting, we begin to measure. -Stephen Hawking","Poor kids are just as bright and just as talented as white kids.– Joe Biden"]
rng = random.choice(quotes)
quote = {"quote": rng}
return render_template("quote.html", rng = rng)
@app.route("/randomnumber")
def number():
min = request.args.get("min")
max = request.args.get("max")
rng = random.randint(int(min), int(max))
number = {"rez": rng,
"min": min,
"max": max
}
return number
@app.route('/password')
def password():
password = ""
no = request.args.get("num")
for _ in range(int(no)):
password += random.choice("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%")
dict = {"word": password, "length": no}
return dict
@app.route('/randDice')
def dice():
sides = request.args.get("sides")
numDices = request.args.get("num")
sc = []
rez = []
sum = 0
for i in range(int(sides)):
sc.append(i)
for i in range(int(numDices)):
rng = random.choice(sc)
rez.append(rng)
sum += rng
dict= {"rez":rez, "sum":sum}
return dict
app.run(host='0.0.0.0', port=8080, debug=True)
```
```html=
<!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>Document</title>
<style>
body{
background-color: rgba(0, 255, 255, 0.4);
}
.btn {
background: #3498db;
background-image: -webkit-linear-gradient(top, #3498db, #2980b9);
background-image: -moz-linear-gradient(top, #3498db, #2980b9);
background-image: -ms-linear-gradient(top, #3498db, #2980b9);
background-image: -o-linear-gradient(top, #3498db, #2980b9);
background-image: linear-gradient(to bottom, #3498db, #2980b9);
-webkit-border-radius: 28;
-moz-border-radius: 28;
border-radius: 28px;
font-family: Arial;
color: #ffffff;
font-size: 20px;
padding: 10px 20px 10px 20px;
text-decoration: none;
}
.btn:hover {
background: #3cb0fd;
background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);
background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);
background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);
background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
text-decoration: none;
}
section{
text-align: center;
}
</style>
</head>
<!-- HARRY MAGURE -->
<body>
<section>
<h1>Vaja Flask vaje</h1>
<a class="btn" href="/coinflip">Coin</a>
<a class="btn" href="/randomquote">Quote</a>
<a class="btn" href="/rndnum">Number</a>
<a class="btn" href="/theword">Password</a>
<a class="btn" href="/dice">Dice</a>
<a class="btn" href="/investing">Investing</a>
</section>
</body>
</html>
```
```html=
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<title>Document</title>
</head>
<body>
<a href="/"><img src="https://cdn-icons-png.flaticon.com/512/93/93634.png" alt="" height="30px"></a>
<h1>Dice</h1>
<input type="number" id="side" placeholder="sides">
<input type="number" id="num" placeholder="number">
<button onclick="dice()">knof</button>
<h3>Rezult</h3>
<div id=rez></div>
<br>
<div id="sum"></div>
<script>
function dice() {
let sides = document.getElementById("side").value;
let num = document.getElementById("num").value;
$.ajax({
url: "/randDice",
data: {
sides:sides,
num:num,
},
success: function( result ) {
rez.innerHTML = result.rez;
sum.innerHTML = result.sum;
}
});
}
</script>
</body>
</html>
```
```html=
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<title>Document</title>
</head>
<body>
<a href="/"><img src="https://cdn-icons-png.flaticon.com/512/93/93634.png" alt="" height="30px"></a>
<h1>Coin Flip</h1>
<button onclick="coinflip()">Flip</button>
<h3 id="rez"></h3>
<img id="img" src="">
<script>
function coinflip() {
$.ajax({
url: "/coinflipper",
success: function( result ) {
img.src = result.img;
rez.innerHTML = result.rez;
}
});
}
</script>
</body>
</html>
```