Added comments
parent
7e59ce88c8
commit
8fcb9ba556
Binary file not shown.
|
@ -0,0 +1,15 @@
|
|||
dfgdfgdfg
|
||||
dfghhh
|
||||
sdfsdfsdfsd
|
||||
ghfghfgh
|
||||
ssdsdf
|
||||
sdsdf
|
||||
sdfsdf
|
||||
dfsdf
|
||||
sdfsfd
|
||||
""
|
||||
sdfsdf
|
||||
""
|
||||
sdffs
|
||||
dfgdfgdfgrtyerte
|
||||
fghfwssdf
|
|
113
main.py
113
main.py
|
@ -1,29 +1,76 @@
|
|||
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('/<username>')
|
||||
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('/<mikrobiologija>')
|
||||
def first_page():
|
||||
return render_template("first_page.html")
|
||||
|
||||
@app.route('/contact/<name>', 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('/<test>')
|
||||
def first_page():
|
||||
return render_template("test.html")
|
||||
|
||||
@app.route('/say_hello/<test>')
|
||||
def greetings(test):
|
||||
return render_template("test.html", test=escape(test))
|
||||
|
||||
|
||||
import unittest
|
||||
|
||||
|
@ -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__":
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
|
@ -1,21 +1,30 @@
|
|||
{% extends "navbar.html" %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
{% block title %}
|
||||
<title>Contact</title>
|
||||
{% endblock title %}
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
||||
crossorigin="anonymous"></script>
|
||||
<link rel="stylesheet" href="dizains.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{{ super () }}
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<h3>Book your first consultation:</h3> <p>Epasts: <strong>example@example.com</strong></p>
|
||||
With whom would you like to book your conslutation?
|
||||
<form method="post" action="{% if name %}{{ url_for('contact_name', name=name) }}{% else %}{{ url_for('contact') }}{% endif %}">
|
||||
<p><input type='text' name='username' placeholder='name'></p>
|
||||
<input type="submit">
|
||||
</form>
|
||||
<p><h3>Book your first consultation with {{name}}:</h3> <p>Epasts: <strong>example@example.com</strong></p>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
|
@ -23,5 +32,24 @@
|
|||
|
||||
<p>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.</p>
|
||||
</div>
|
||||
{% if name %}
|
||||
<form method="post" action="{% if name %}{{ url_for('contact_name', name=name) }}{% else %}{{ url_for('contact') }}{% endif %}">
|
||||
<label for="subject">Subject</label>
|
||||
<textarea id="subject" name="subject" placeholder="Write something.." style="height:200px"></textarea>
|
||||
|
||||
<input type="submit" value="Submit">
|
||||
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% if comments %}
|
||||
{% for comment in comments %}
|
||||
<p>{{comment}}</p>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% endblock content %}
|
||||
{{ super() }}
|
||||
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
|
@ -1,3 +1,4 @@
|
|||
{% extends "navbar.html" %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
|
@ -13,13 +14,43 @@
|
|||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
||||
crossorigin="anonymous"></script>
|
||||
|
||||
<script>
|
||||
function togglePassword() {
|
||||
var x = document.getElementById("password");
|
||||
if (x.type === "password") {
|
||||
x.type = "text";
|
||||
} else {
|
||||
x.type = "password";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
functionremember_me()
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
{{ super () }}
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
|
||||
|
||||
<form method="post">
|
||||
<p><input type='text' name='username'>
|
||||
<p><input type='submit' value='Login'>
|
||||
<p><input type='text' name='username' placeholder='Username'></p>
|
||||
<p>
|
||||
<input type='password' id='password' name='password' placeholder='Password'>
|
||||
<input type='checkbox' onclick="togglePassword()"> Show Password
|
||||
</p>
|
||||
<p><input type='email' name='email' placeholder='Email'></p>
|
||||
<p>
|
||||
<input type='checkbox' name='remember' value="yes">Remember Me</input>
|
||||
</p>
|
||||
<p><input type='submit' value='Login'></p>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
{% endblock content %}
|
||||
{{ super() }}
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,29 @@
|
|||
{% extends "navbar.html" %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>HTML 5 Boilerplate</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
||||
crossorigin="anonymous"></script>
|
||||
</head>
|
||||
<body>
|
||||
{{ super () }}
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<h1>Get to know your true self!</h1>
|
||||
<a href='/contact'>Book your ticket to the paradise!</a>
|
||||
<p>or read about microbiology! Firstly, <a href='/login'> login </a></p>!
|
||||
</div>
|
||||
|
||||
{% endblock content %}
|
||||
{{ super() }}
|
||||
</body>
|
||||
</html>
|
|
@ -1,3 +1,4 @@
|
|||
{% extends "navbar.html" %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
|
@ -8,55 +9,18 @@
|
|||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>HTML 5 Boilerplate</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
{{ super () }}
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
{% if name %}
|
||||
<h1>Hello, {{ name }}</h1>
|
||||
{% else %}
|
||||
<h1>Hello, unknown</h1>
|
||||
<h1><span class='otherStyle' >Hello, unknow </span></h1>
|
||||
{% endif %}
|
||||
<div class="container">
|
||||
|
||||
<nav class="navbar navbar-expand-lg bg-body-tertiary" data-bs-theme="dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Dažādu priekšmetu hub</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
|
||||
data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Galvenā lapa</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Jaunākie raksti</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
Tēmas
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Fizika</a></li>
|
||||
<li><a class="dropdown-item" href="#">Ķīmija</a></li>
|
||||
<li><a class="dropdown-item" href="#">Bioloģija</a></li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><a class="dropdown-item" href="#">Random tēmu ģenerators</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<a class="btn btn-primary" href="/login">Login</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<br />
|
||||
<h1>Mikrobioloģija</h1>
|
||||
<div class="Informācijas apkopojums">
|
||||
|
@ -107,18 +71,19 @@
|
|||
<h3 class="special-header">Pagājušo gadu ZPD tēmas</h3>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-3">Mikrobiālā daudzveidība un ekosistēmu stabilitāte</div>
|
||||
<div class="col-6">Antibiotiku rezistence: Izšķirošais izaicinājums mūsdienu medicīnā</div>
|
||||
<div class="col-3">Probiotikas un cilvēka veselība</div>
|
||||
|
||||
<div class="col-sm-3">Mikrobiālā daudzveidība un ekosistēmu stabilitāte</div>
|
||||
<div class="col-sm-6">Antibiotiku rezistence: Izšķirošais izaicinājums mūsdienu medicīnā</div>
|
||||
<div class="col-sm-3">Probiotikas un cilvēka veselība</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Mikrobiālās infekcijas un to kontrole</div>
|
||||
<div class="col-4">Mikrobioloģija un pārtikas drošība</div>
|
||||
<div class="col-4">Mikrobiālās saskares ar cilvēku: Symbioze un patogēnija</div>
|
||||
<div class="col-sm-4">Mikrobiālās infekcijas un to kontrole</div>
|
||||
<div class="col-sm-4">Mikrobioloģija un pārtikas drošība</div>
|
||||
<div class="col-sm-4">Mikrobiālās saskares ar cilvēku: Symbioze un patogēnija</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">Mikrobioloģija un vides ilgtspēja</div>
|
||||
<div class="col-6">Infekcijas slimību izplatīšanās</div>
|
||||
<div class="col-sm-6">Mikrobioloģija un vides ilgtspēja</div>
|
||||
<div class="col-sm-6">Infekcijas slimību izplatīšanās</div>
|
||||
</div>
|
||||
</div>
|
||||
<h4 class="special-header">Citas jautrās mikrobioloģijas tēmas:</h4>
|
||||
|
@ -186,8 +151,8 @@
|
|||
<button type="button" class="btn btn-danger">Epidemioloģija </button>
|
||||
<button type="button" class="btn btn-warning">Mikrobiālā ģenētika</button>
|
||||
</div>
|
||||
<h1>Get to know your true self!</h1>
|
||||
<a href='/contact'>Book your ticket to the paradise!</a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
{% endblock content %}
|
||||
{{ super() }}
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,70 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>HTML 5 Boilerplate</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
{% block title %}
|
||||
<title>My Webpage</title>
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="footer">
|
||||
|
||||
<div class="container">
|
||||
{% block navbar %}
|
||||
<nav class="navbar navbar-expand-lg bg-body-tertiary" data-bs-theme="dark">
|
||||
<div class="container-fluid">
|
||||
<a class="text-wrap navbar-brand" href="/">Dažādu priekšmetu hub</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
|
||||
data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="/">Galvenā lapa</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Jaunākie raksti</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
Tēmas
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="/login">Fizika</a></li>
|
||||
<li><a class="dropdown-item" href="/login">Ķīmija</a></li>
|
||||
<li><a class="dropdown-item" href="/login">Bioloģija</a></li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><a class="dropdown-item" href="#">Random tēmu ģenerators</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<a class="btn btn-primary" href="/login">Login</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{% endblock navbar %}
|
||||
|
||||
{% block content %}
|
||||
<div id="content"></div>
|
||||
{% endblock %}
|
||||
|
||||
{% block footer %}
|
||||
Copyright 2008 by <a href="http://domain.invalid/">you</a>.
|
||||
{% endblock %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
import unittest
|
||||
<html>
|
||||
|
||||
<head>
|
||||
|
@ -16,7 +15,7 @@ import unittest
|
|||
|
||||
<body>
|
||||
<div class="container">
|
||||
|
||||
<h1>Hi {{ test }}!</h1>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue