diff --git a/README.md b/README.md index a2c6c1d..324a7b3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -[![Open in Visual Studio Code](https://classroom.github.com/assets/open-in-vscode-c66648af7eb3fe8bc4f294546bfd86ef473780cde1dea487d3c4ff354943c9ae.svg)](https://classroom.github.com/online_ide?assignment_repo_id=8703052&assignment_repo_type=AssignmentRepo) Flask Start OneFile ========================= diff --git a/static/img/maliny.jpg b/static/img/maliny.jpg new file mode 100644 index 0000000..5ad008e Binary files /dev/null and b/static/img/maliny.jpg differ diff --git a/static/styles.css b/static/styles.css index 05e75c2..e4b4043 100644 --- a/static/styles.css +++ b/static/styles.css @@ -1,5 +1,5 @@ body { - background-color: rgb(50, 182, 205); + background-color: #eeeeee; padding-left: 1em; padding-right: 1em; margin-left: 90px; @@ -10,14 +10,6 @@ h1, h2, h3 { margin-top: 3em; } -h1 { - color: green; -} - -h2 { - color: blue; -} - h1 a { color: #bb8800; } @@ -34,13 +26,13 @@ nav ul { } nav ul li a { display: block; - color: rgb(199, 18, 48); - background-color: #6fd80d; + color: white; + background-color: #324b79; border-radius: 25px 50px 0px; padding: 1ex 2ex; } nav ul li a:hover { color: #324b72; - background-color: rgb(175, 9, 9); + background-color: white; } nav img { float:left; diff --git a/templates/abc.html b/templates/abc.html index 241887c..fdd55c2 100644 --- a/templates/abc.html +++ b/templates/abc.html @@ -27,4 +27,3 @@

Flask pokus

{% endblock obsah %} - diff --git a/templates/banan.html b/templates/banan.html deleted file mode 100644 index e931883..0000000 --- a/templates/banan.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends 'base.html' %} - - -{% block obsah %} - -

Formulář

-
- - - -
- - - - - -

Banan

-

miluju banan

-

-{% endblock obsah %} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 3b2ef59..c962a26 100644 --- a/templates/base.html +++ b/templates/base.html @@ -24,22 +24,26 @@
  • Index
  • Info
  • ABC
  • -
  • Banan
  • +
  • Malina
  • {% block obsah %} -{#{% filter markdown %}#} -# Flask +

    Flask

    -Startovací šablona pro webový framework Flask. -![Flaštička]({{ url_for('static', filename='flask.png') }}) -![Flaštičky]({{ url_for('static', filename='flasks.png') }}) +

    Startovací šablona pro webový framework Flask.

    -{#{% endfilter %}#} +

    + +

    Lorem ipsum dolor sit amet consectetur adipisicing elit. +Laboriosam velit ut, ipsam sit a, quod et quia ducimus dolor vitae +recusandae! Exercitationem quae expedita cum delectus laboriosam +minus voluptatem rerum.

    + +

    diff --git a/templates/malina.html b/templates/malina.html new file mode 100644 index 0000000..7198f3c --- /dev/null +++ b/templates/malina.html @@ -0,0 +1,50 @@ +{% extends 'base.html' %} + + +{% block obsah %} + +

    Malina a BMI

    + +

    formulář

    +
    +

    Hmotnost:
    + kg +

    +

    Výška:
    + cm +

    +

    +
    +{% if bmi != none %} +

    BMI={{bmi}}

    + +{% if bmi < 18.5%} +

    0 až 18.5 podváha

    +{% elif bmi < 25%} +

    18.5 až 25 normalni vaha

    +{% elif bmi < 30%} +

    25 až 30 nadvaha

    +{% elif bmi < 35%} +

    30 až 35 mirna obezita

    +{% elif bmi < 40%} +

    35 až 40 obezita

    +{% elif bmi > 40%} +

    více než 40 extrem obezita

    +{% endif %} + + +{% else %} +

    je treba zadat dve nenulova cisla!

    +{% endif %} + + +

    + +{% for i in range(7) %} +

    Maliny jsou nejlepší!

    +{% endfor %} + + +{% endblock obsah %} diff --git a/webface.py b/webface.py index 5ce68a7..2dc3c19 100644 --- a/webface.py +++ b/webface.py @@ -1,4 +1,4 @@ -from crypt import methods +from decimal import DivisionByZero from flask import Flask, render_template, request, redirect, url_for, session import functools @@ -37,18 +37,23 @@ def info(): def abc(): return render_template("abc.html", slova=slova) -@app.route("/banan/", methods=["GET", "POST"]) -def banan(): - return render_template("banan.html") -@app.route("/text/") -def text(): - return """ +@app.route("/malina/", methods=['GET', 'POST']) +def malina(): + hmotnost = request.args.get('hmotnost') + vyska = request.args.get('vyska') -

    Text

    + print(hmotnost, vyska) + if hmotnost and vyska: + try: + hmotnost = float(hmotnost) + vyska=float(vyska) + bmi = hmotnost/(0.01*vyska)**2 + except (DivisionByZero, ValueError): + bmi = None + else: + bmi = None -

    toto je text

    - -""" + return render_template('malina.html', bmi=bmi) \ No newline at end of file