You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1023 B
47 lines
1023 B
from flask import Flask, jsonify
|
|
import random
|
|
import datetime
|
|
|
|
app = Flask(__name__)
|
|
hostname = "Prijmeni_API"
|
|
|
|
|
|
@app.route("/api/teplota")
|
|
def teplota():
|
|
teplota_hodnota = random.randint(10,30)
|
|
cas = datetime.datetime.now().isoformat()
|
|
data = {
|
|
"hodnota":teplota_hodnota,
|
|
"cas":cas,
|
|
"hostname":hostname
|
|
}
|
|
return jsonify(data)
|
|
|
|
@app.route("/api/vlhkost")
|
|
def vlhkost():
|
|
vlhkost_hodnota = random.randint(2,95)
|
|
cas = datetime.datetime.now().isoformat()
|
|
data = {
|
|
"hodnota":vlhkost_hodnota,
|
|
"cas":cas,
|
|
"hostname":hostname
|
|
}
|
|
return jsonify(data)
|
|
|
|
@app.route("/api")
|
|
def all():
|
|
vlhkost_hodnota = random.randint(2,95)
|
|
teplota_hodnota = random.randint(10,30)
|
|
cas = datetime.datetime.now().isoformat()
|
|
data = {
|
|
"vlhkost":vlhkost_hodnota,
|
|
"teplota": teplota_hodnota,
|
|
"cas":cas,
|
|
"hostname":hostname
|
|
}
|
|
return jsonify(data)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app.run(host="0.0.0.0",port=5000)
|