diff --git a/.nfs0000000001aa066600000010 b/.nfs0000000001aa066600000010 new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index 7244e12..e3d3995 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Open in Visual Studio Code](https://classroom.github.com/assets/open-in-vscode-c66648af7eb3fe8bc4f294546bfd86ef473780cde1dea487d3c4ff354943c9ae.svg)](https://classroom.github.com/online_ide?assignment_repo_id=8703051&assignment_repo_type=AssignmentRepo) +[![Open in Visual Studio Code](https://classroom.github.com/assets/open-in-vscode-c66648af7eb3fe8bc4f294546bfd86ef473780cde1dea487d3c4ff354943c9ae.svg)](https://classroom.github.com/online_ide?assignment_repo_id=8703049&assignment_repo_type=AssignmentRepo) Flask Start OneFile ========================= diff --git a/data.db b/data.db new file mode 100644 index 0000000..72ae65d Binary files /dev/null and b/data.db differ diff --git "a/static/ban\303\241n.jpeg" "b/static/ban\303\241n.jpeg" new file mode 100644 index 0000000..eeb9f93 Binary files /dev/null and "b/static/ban\303\241n.jpeg" differ diff --git a/static/styles.css b/static/styles.css index b83f830..07ad138 100644 --- a/static/styles.css +++ b/static/styles.css @@ -1,5 +1,5 @@ body { - background-color: #e6ab09; + background-color: #ea0079; padding-left: 1em; padding-right: 1em; margin-left: 90px; @@ -8,11 +8,11 @@ body { h1, h2, h3 { clear: both; margin-top: 3em; - color: violet; + color: #0aec0a; } h1 a { - color: #bb8800; + color: #0aec0a; } nav ul { @@ -27,12 +27,12 @@ nav ul { } nav ul li a { display: block; - color: white; - background-color: #324b79; + color: rgb(0, 30, 255); + background-color: #7bff00; border-radius: 25px 50px 0px; padding: 1ex 2ex; } nav ul li a:hover { - color: #324b72; + color: #5e12a6; background-color: white; } nav img { @@ -46,6 +46,7 @@ footer { background-color: #ecc8f0; } .login { + display: block; float: right; width: 30%; border: orange solid 2px; @@ -59,21 +60,19 @@ footer { background-color: lightblue; } -.flash { +.flash{ display: block; - position: absolute; + position: absolute; + left: 30%; + top: 1ex; width: 40%; - border: 2px orangered solid; - border-radius: 20px; + border: 2px orange solid; padding: 2ex; - left: 30%; - top: 0; - + border-radius: 20px; + font-weight: bold; } - .error{ - background-color: red; - color: black; - + background-color: white; + color: red; } /*# sourceMappingURL=styles.css.map */ diff --git a/templates/banan.html b/templates/banan.html new file mode 100644 index 0000000..38ec8a9 --- /dev/null +++ b/templates/banan.html @@ -0,0 +1,28 @@ + +{% extends 'base.html' %} + +{%block title%}Informace{%endblock%} + +{% block obsah %} + +

Miluju banany, BMI

+ +

+

formulář

+
+ Hmotnost:
kg
+ Výška:
cm
+ + + +
+

BMI={{bmi}}

+ + + + + + + + +{% endblock obsah %} diff --git a/templates/base.html b/templates/base.html index 90358c8..4eae675 100644 --- a/templates/base.html +++ b/templates/base.html @@ -16,38 +16,33 @@ Fork me on GitHub +

- -

- -{% if 'uzivatel' in session %} - jsi prihlaseny jako {{session ['uzivatel']}} odhlasit se - +{% if 'uživatel' in session %} +jsi přihlášen jako Najvetší lupič {% else %} -nejsi prihlaseny Prihlas se +Jaaaaj!!! Nejsi přihlášen Přihlas se! {% endif %}

- - - - +{% for category,message in get_flashed_messages(with_categories=true) %} +

+ +{{message}} +

+{% endfor %} - -{% for category, message in get_flashed_messages(with_categories=true) %} -

{{message}}

-{% endfor %} {% block obsah %} @@ -79,6 +74,7 @@ {#{% endfilter %}#} + - diff --git a/templates/login.html b/templates/login.html index 75ef885..76d3de7 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1,24 +1,19 @@ {% extends 'base.html' %} -{%block title%}Informace{%endblock%} +{%block title%}Login{%endblock%} {% block obsah %}

Login

-

zde se muzes prihlasit

- - -
- jmeno


- heslo


- - - +

zde se mužeš přihlásit

+ + jméno:

+ heslo:
+
+
+
- - - {% endblock obsah %} diff --git a/webface.py b/webface.py index cab6c11..bd49621 100644 --- a/webface.py +++ b/webface.py @@ -1,6 +1,6 @@ +from pickle import GET from flask import Flask, render_template, request, redirect, url_for, session, flash import functools -from werkzeug.security import generate_password_hash, check_password_hash # from werkzeug.security import generate_password_hash, check_password_hash @@ -34,33 +34,30 @@ def index(): def info(): return render_template("info.html") -@app.route("/pomerance/" , methods = ['GET', 'POST']) -def pomerance(): - if 'uzivatel' not in session: - flash('jsi ty vubec normalni? nejsi prihlaseny ', 'error') - return redirect(url_for('login')) - - hmotnost = request.args.get('hmotnost') - vyska = request.args.get('vyska') - - print(hmotnost, vyska) - if hmotnost and vyska : - try: - metry = int(vyska)/100 - bmi = int(hmotnost)/metry**2 - except (ZeroDivisionError, ValueError): - bmi = None - else: - bmi = None - - print(bmi) - return render_template("pomerance.html", bmi=bmi) - @app.route("/abc/") def abc(): + if 'uživatel' not in session: + flash('Nejsi příhlášen, tato stránka vyžaduje přihlášení.', 'error') + return redirect(url_for('login', page=request.full_path)) return render_template("abc.html", slova=slova) +@app.route("/banan/", methods=["GET", "POST"]) +def banan(): + if 'uživatel' not in session: + flash('Nejsi příhlášen, tato stránka vyžaduje přihlášení.', 'error') + return redirect(url_for('login', page=request.full_path)) + + hmotnost= request.args.get("hmotnost") + + výška= request.args.get("výška") + + print(hmotnost, výška) + if hmotnost and výška != None : + bmi=int(hmotnost) / ((int(výška)/100)**2) + else: + bmi = 0 + return render_template("banan.html", bmi=bmi) @app.route("/text/") def text(): @@ -101,12 +98,12 @@ def login_post(): return redirect( url_for ('login', page=page)) return redirect( url_for ('login')) #stejne jako funkce get, jen jiný zápis - #od martina -@app.route("/logout/", methods = ['GET', 'POST']) +@app.route("/logout/", methods=["GET"]) def logout(): - session.pop('uzivatel', None) - return redirect(url_for('index')) + session.pop('uživatel', None) + return redirect( url_for ('login')) + @app.route("/registr/", methods = ['GET']) def registr(): @@ -140,4 +137,4 @@ def registr_post(): flash('Nespávné přihlašovací udaje','error') if page: return redirect( url_for ('login', page=page)) - return redirect( url_for ('pomerance')) + return redirect( url_for ('pomerance')) \ No newline at end of file