From 8fcb9ba55650941fbf03711f65f6d269a48c3992 Mon Sep 17 00:00:00 2001 From: Kaspirka Date: Thu, 16 May 2024 14:42:50 +0300 Subject: [PATCH] Added comments --- __pycache__/main.cpython-311.pyc | Bin 3030 -> 6771 bytes comments.csv | 15 +++ main.py | 113 +++++++++--------- static/style.css | 17 +++ style.css | 5 - templates/contact.html | 32 +++++- templates/first_page.html | 189 ------------------------------- templates/form.html | 37 +++++- templates/home.html | 29 +++++ templates/index.html | 71 +++--------- templates/navbar.html | 70 ++++++++++++ templates/test.html | 3 +- users.csv | 3 + 13 files changed, 279 insertions(+), 305 deletions(-) create mode 100644 comments.csv create mode 100644 static/style.css delete mode 100644 style.css delete mode 100644 templates/first_page.html create mode 100644 templates/home.html create mode 100644 templates/navbar.html create mode 100644 users.csv diff --git a/__pycache__/main.cpython-311.pyc b/__pycache__/main.cpython-311.pyc index 46dc30156239bcf3bff084320b3ba4cad5a7e3c8..a80bb68a506a1feadb8b3d6cc9e63283e81c364f 100644 GIT binary patch literal 6771 zcmbste{2)i`JM01KKtz0!D$i)NCK1*xNMGOf`>m*NN3`8a|sg=t2!#Yg#+GwNgz??}2*LR2vOY|a)u# zbxAEvTml<%@o&H-(DWXy8}ew~fXAjL9-B7g5p39twx+p3&?B2{i?*3sdJVMHF1KBH zt-8^7S=e>>m0Pr3_DCHUO%2i@XuIt~M-?Y^u7>QZfnBgu<}bYY8Ipya27e+MS1ua9 zRQ#eGqq4G)Nh`A9r*c}7X-t(<3(2@D8!jq;v?wd8Ay8RLPo4H zHohQF&Q{mP|Ej^g=!S>eL?%&2B2kCLL|MtPLZY0+0^}ubiiCNCdry(+GbfPFT5ksr z_-6S0VmpA_B+Fz;40`33b-+_~8LbM9z`|8Sh{Y1= zgc^%2`Ec4m_0f$?+W{<-l81!0<+$s8g68n~;K2;+Nzlx2Xv1;xy$B zfMxR3*LtHbuiQJP`65MMME6BX#Nj^j@U5qzEuVK4CW@hcJ=C9jd(GSajko8Cx2Mo{ zXX``m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-VdzD5AoU~h6Xy8m nsW*st&wleSN3`pRKIQ}MtDS3m*E`qS_BV7OejXfxy{rEKYLi~b diff --git a/comments.csv b/comments.csv new file mode 100644 index 0000000..d4e191f --- /dev/null +++ b/comments.csv @@ -0,0 +1,15 @@ +dfgdfgdfg +dfghhh +sdfsdfsdfsd +ghfghfgh +ssdsdf +sdsdf +sdfsdf +dfsdf +sdfsfd +"" +sdfsdf +"" +sdffs +dfgdfgdfgrtyerte +fghfwssdf diff --git a/main.py b/main.py index 080851f..4bee564 100644 --- a/main.py +++ b/main.py @@ -1,30 +1,77 @@ from flask import Flask, make_response, render_template, request, redirect, url_for from markupsafe import escape - +import csv app = Flask(__name__) +class User: + MAX_CHAIR_AMOUNT = 6 + + def __init__( + self, + username, + email + ): + self.username = username + self.email = email + + def save(self): + with open('users.csv', 'a', newline='') as csvfile: + spamwriter = csv.writer(csvfile) + spamwriter.writerow([self.username, self.email]) + @app.route('/') +def home(): + return render_template("home.html") + @app.route('/') def index(username = None): return render_template("index.html", name = username) -@app.route('/contact') -def contact(): +@app.route('/contact', methods=['GET', 'POST']) +def contact(name=None): + if request.method == 'POST': + username = request.form['username'] + return redirect(url_for('contact_name', name=escape(username))) return render_template("contact.html") -@app.route('/') -@app.route('/') -def first_page(): - return render_template("first_page.html") + +@app.route('/contact/', methods=['GET', 'POST']) +def contact_name(name): + if request.method == 'POST': + comment = request.form['subject'] + print(comment) + with open('comments.csv', 'a', newline='') as csvfile: + spamwriter = csv.writer(csvfile) + spamwriter.writerow([comment]) + + comments = [] + with open('comments.csv', 'r', newline='') as csvfile: + spamreader = csv.reader(csvfile) + for row in spamreader: + comments.append(str(row[0])) + + print(comments) + return render_template('contact.html', name=escape(name), comments=comments) + return render_template("contact.html", name=name) + @app.route('/login', methods=['GET', 'POST']) def login(): if request.method == 'POST': username = request.form['username'] + email = request.form['email'] + remember = request.form.get('remember') + + if remember == 'yes': + user = User(username, email) + user.save() + return redirect(url_for('index', username=escape(username))) return render_template("form.html") -@app.route('/') -def first_page(): - return render_template("test.html") +@app.route('/say_hello/') +def greetings(test): + return render_template("test.html", test=escape(test)) + + import unittest class TestStringMethods(unittest.TestCase): @@ -34,48 +81,12 @@ class TestStringMethods(unittest.TestCase): response = client.get(response.location) self.assertEqual(response.status_code, 200) self.assertIn("Test", response.text) - # ... - -class TestCategorizeByAge(unittest.TestCase): - def test_child(self): - """Test for 'Child'""" - self.assertEqual(categorize_by_age(5), "Child") - - def test_adolescent(self): - """Test for 'Adolescent'""" - self.assertEqual(categorize_by_age(15), "Adolescent") - - def test_adult(self): - """Test for 'Adult'""" - self.assertEqual(categorize_by_age(30), "Adult") - - def test_golden_age(self): - """Test for 'Golden age'""" - self.assertEqual(categorize_by_age(70), "Golden age") - - def test_negative_age(self): - """Test for negative age""" - self.assertEqual(categorize_by_age(-1), "Invalid age: -1") - - def test_too_old(self): - """Test for too old""" - self.assertEqual(categorize_by_age(151), "Invalid age: 151") - - def test_boundary_child_adolescent(self): - """Test for boundary between 'Child' and 'Adolescent'""" - self.assertEqual(categorize_by_age(9), "Child") - self.assertEqual(categorize_by_age(10), "Adolescent") - - def test_boundary_adolescent_adult(self): - """Test for boundary between 'Adolescent' and 'Adult'""" - self.assertEqual(categorize_by_age(18), "Adolescent") - self.assertEqual(categorize_by_age(19), "Adult") - - def test_boundary_adult_golden_age(self): - """Test for boundary between 'Adult' and 'Golden age'""" - self.assertEqual(categorize_by_age(65), "Adult") - self.assertEqual(categorize_by_age(66), "Golden age") + def test_test(self): + client = app.test_client() + response = client.get("/say_hello/Maria") + self.assertEqual(response.status_code, 200) + self.assertIn("Hi Maria!", response.text) if __name__ == "__main__": diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..bfb9576 --- /dev/null +++ b/static/style.css @@ -0,0 +1,17 @@ +.otherStyle { + color: black; + font-size: 60px; + font-family: 'Lucida Handwriting', cursive; + } +h1 { + color: black; + font-size: 50px; + font-family: 'Arial', Sans-serif; + } + +.col-sm-4, .col-sm-3, .col-sm-6, .col-sm-12{ + background-color: purple; + border: 4px solid yellow; + color: white + +} \ No newline at end of file diff --git a/style.css b/style.css deleted file mode 100644 index 578aaba..0000000 --- a/style.css +++ /dev/null @@ -1,5 +0,0 @@ -h1 { - color: red; - font-size: 5px; - } - \ No newline at end of file diff --git a/templates/contact.html b/templates/contact.html index 2b030c3..02e977d 100644 --- a/templates/contact.html +++ b/templates/contact.html @@ -1,21 +1,30 @@ +{% extends "navbar.html" %} + {% block title %} Contact + {% endblock title %} - + {{ super () }} + {% block content %}
-

Book your first consultation:

Epasts: example@example.com

+ With whom would you like to book your conslutation? +
+

+ +
+

Book your first consultation with {{name}}:

Epasts: example@example.com

Mūsu konsultācijas maģiskais efekts ir kā burvju triks, kurā pazūd visi jūsu stresi un neērtības. Pēc seansa jūs sajutīsiet, ka jūsu redze ir kļuvusi tik asa, ka jūs spējat saskatīt katru putekli uz sava dīvāna - pat tos, kurus mēģinājāt ignorēt jau mēnešiem. Jūsu acis kļūst tik spēcīgas, ka jūs varētu mierīgi izlasīt smalko druku uz līguma, kuru parasti vienkārši parakstāt, neko nelasot.

@@ -23,5 +32,24 @@

Un, protams, taustes sajūtas pēc mūsu konsultācijas ir kaut kas neizsakāms! Pēc seansa, kad pieskarsieties savai mīļākajai kafijas tasītei, jūs sajutīsiet katru porcelāna izliekumu un katru niecīgāko siltuma viļņu, it kā tā būtu jūsu pašu rokas pagarinājums. Jūsu āda kļūs tik jutīga, ka pat kaķa spalvas kļūs par greznu samtu, un ikviens rokasspiediens - par mīļo apskāvienu. Tas ir kā dzīvot pasakā, kur viss ir daudz krāsaināks, skaļāks un taustāmāks.

+ {% if name %} +
+ + + + + +
+ {% endif %} + + {% if comments %} + {% for comment in comments %} +

{{comment}}

+ {% endfor %} + {% endif %} + + {% endblock content %} + {{ super() }} + \ No newline at end of file diff --git a/templates/first_page.html b/templates/first_page.html deleted file mode 100644 index 2e5a200..0000000 --- a/templates/first_page.html +++ /dev/null @@ -1,189 +0,0 @@ - - - - - - Vissvarīgākā tēma - - - - - - - -
- - -
-

Mikrobioloģija

-
- -

Mana motivācija

-
-
Man patīk mikrobioloģija, jo tā ir aizraujoša zinātnes joma, kas pēta mikroorganismus - - neredzamos dzīvības veidus, kas ietekmē visu no veselības līdz vides ilgtspējai. - Mikrobioloģija sniedz ieskatu mikroorganismu pasaules sarežģītajā un fascinējošajā dzīvē, atklājot to - lomu cilvēku veselībā, pārtikas ražošanā un dabas ekosistēmās. - Mani aizrauj mikrobioloģijas pētījumi, jo tie dod iespēju iedziļināties mikrobu pasaulē, saprast to - potenciālu un izmantot šo zinātnes jomu, lai risinātu dažādus globālus izaicinājumus.
-
-

Kas ir mikrobioloģija?

-

Mikrobioloģija ir zinātnes joma, kas pēta mikroorganismus - mikroskopiskus dzīvniekus, augus, sēnes un - vīrusus. Šī zinātne aptver plašu spektru tematu, sākot no mikrobu struktūras un fiziskajām īpašībām līdz to - fizjoloģiskajām funkcijām un ekoloģiskajai nozīmei.

-

Mikrobioloģija ir svarīga medicīnā, pārtikas rūpniecībā, - lauksaimniecībā, vides pētījumos un biotehnoloģijās. Tajā tiek izmantotas dažādas metodes, tostarp - mikroskopija, genētika, bioķīmija un molekulārā bioloģija, lai izpētītu un saprastu mikroorganismu uzvedību - un ietekmi uz dzīvo organismu un vidi kopumā. Mikrobioloģija ir dinamisks un strauji attīstošs lauks, kas - sniedz būtisku ieguldījumu cilvēku veselības, pārtikas drošības un vides ilgtspējas uzlabošanā.

- -

Kāpēc mikrobioloģija ir svarīga?

-
    -
  • Veselības uzlabošana
  • -
  • Pārtikas drošība
  • -
  • Ekosistēmu ilgtspēja
  • -
- - Vairāk - informācijas par mikrobioloģiju - -
- - Skaistums - Zils skaistums - Cits skaistums - -
- - -

Pagājušo gadu ZPD tēmas

-
-
-
Mikrobiālā daudzveidība un ekosistēmu stabilitāte
-
Antibiotiku rezistence: Izšķirošais izaicinājums mūsdienu medicīnā
-
Probiotikas un cilvēka veselība
-
-
-
Mikrobiālās infekcijas un to kontrole
-
Mikrobioloģija un pārtikas drošība
-
Mikrobiālās saskares ar cilvēku: Symbioze un patogēnija
-
-
-
Mikrobioloģija un vides ilgtspēja
-
Infekcijas slimību izplatīšanās
-
-
-

Citas jautrās mikrobioloģijas tēmas:

- - - - - - - - - - - - - - -
Interesanti Eksotiski
Mikrobu dzīvesveidsBiotehnoloģijas un mikrobioloģija
Bakteriju nomenklatūra Mikrobu laboratorijas procedūras
- -
-

Citi raksti par mikrobioloģiju

- -
-
- ... -
-
Bakterioloģija
-

Pētījumi par baktērijām, to struktūru, ģenētiku un funkcijām. -

- Vairāk -
-
- -
- ... -
-
Vīrusoloģija
-

Zinātne par vīrusiem, to ietekmi uz dzīvajiem organismiem un - infekciju mehānismiem.

- Vairāk -
-
- -
- ... -
-
Mikoloģija
-

Pētījumi par sēnēm un to īpašībām, tostarp sēnīšu infekcijām un to - bioloģiju.

- Vairāk -
-
-
- - -
-

Vairāk pirekšmetu:

-
- - - - - -
- - - diff --git a/templates/form.html b/templates/form.html index 458db3e..2463e02 100644 --- a/templates/form.html +++ b/templates/form.html @@ -1,3 +1,4 @@ +{% extends "navbar.html" %} @@ -13,13 +14,43 @@ integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"> + + + + {{ super () }} + {% block content %}
+ +
-

-

-

+

+

+ + Show Password +

+

+

+ Remember Me +

+

+ + +
+ {% endblock content %} + {{ super() }} \ No newline at end of file diff --git a/templates/home.html b/templates/home.html new file mode 100644 index 0000000..f256b3d --- /dev/null +++ b/templates/home.html @@ -0,0 +1,29 @@ +{% extends "navbar.html" %} + + + + + + + + HTML 5 Boilerplate + + + + + + {{ super () }} + {% block content %} +
+

Get to know your true self!

+ Book your ticket to the paradise! +

or read about microbiology! Firstly, login

! +
+ + {% endblock content %} + {{ super() }} + + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 6eb566e..e9d1501 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,3 +1,4 @@ +{% extends "navbar.html" %} @@ -8,55 +9,18 @@ HTML 5 Boilerplate - + + {{ super () }} + {% block content %}
{% if name %}

Hello, {{ name }}

{% else %} -

Hello, unknown

+

Hello, unknow

{% endif %}
- -

Mikrobioloģija

@@ -107,18 +71,19 @@

Pagājušo gadu ZPD tēmas

-
Mikrobiālā daudzveidība un ekosistēmu stabilitāte
-
Antibiotiku rezistence: Izšķirošais izaicinājums mūsdienu medicīnā
-
Probiotikas un cilvēka veselība
+ +
Mikrobiālā daudzveidība un ekosistēmu stabilitāte
+
Antibiotiku rezistence: Izšķirošais izaicinājums mūsdienu medicīnā
+
Probiotikas un cilvēka veselība
-
Mikrobiālās infekcijas un to kontrole
-
Mikrobioloģija un pārtikas drošība
-
Mikrobiālās saskares ar cilvēku: Symbioze un patogēnija
+
Mikrobiālās infekcijas un to kontrole
+
Mikrobioloģija un pārtikas drošība
+
Mikrobiālās saskares ar cilvēku: Symbioze un patogēnija
-
Mikrobioloģija un vides ilgtspēja
-
Infekcijas slimību izplatīšanās
+
Mikrobioloģija un vides ilgtspēja
+
Infekcijas slimību izplatīšanās

Citas jautrās mikrobioloģijas tēmas:

@@ -186,8 +151,8 @@
-

Get to know your true self!

- Book your ticket to the paradise! -
- + + {% endblock content %} + {{ super() }} + \ No newline at end of file diff --git a/templates/navbar.html b/templates/navbar.html new file mode 100644 index 0000000..7130db5 --- /dev/null +++ b/templates/navbar.html @@ -0,0 +1,70 @@ + + + + + + + + + HTML 5 Boilerplate + + {% block title %} + My Webpage + {% endblock %} + + + +