Rename jpg file

This commit is contained in:
Zaytseva Anastasiia 2024-12-30 21:53:10 +03:00 committed by Zaytseva Anastasiia
parent a2d06c2907
commit e0859a05c6
20 changed files with 529 additions and 90 deletions

1
.pylintrc Normal file
View File

@ -0,0 +1 @@
disable=missing-function-docstring

13
Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY site /app/site
EXPOSE 5000
CMD ["python", "site/app.py"]

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
Flask==2.0.1
Werkzeug==2.3.7

View File

@ -1,24 +1,121 @@
from flask import Flask, render_template, request from flask import Flask, render_template, request
app = Flask(__name__) class BaldursGateQuizApp:
def __init__(self):
self.app = Flask(__name__, template_folder="templates", static_folder="static")
self.add_routes()
@app.route('/') def add_routes(self):
def index(): self.app.add_url_rule('/', 'index', self.index)
return render_template("index.html") self.app.add_url_rule('/result', 'result', self.result, methods=["POST"])
self.app.add_url_rule('/tests', 'tests', self.tests)
self.app.add_url_rule('/about', 'about', self.about)
@app.route("/result", mathods=["POST"]) def index(self):
def result(): return render_template("index.html")
answers = request.form
character = determine_character(answers)
return render_template("result.html", character=character)
def datermine_character(answers): def tests(self):
if answers.get("question1") == "brave": return render_template("tests.html")
return "Minsc"
elif answers.get("question1") == "wise":
return "Jeheira"
else:
return "Imoem"
if __name__=="__main__": def result(self):
app.run(debug=True) answers = request.form
character = self.determine_character(answers)
return render_template("result.html", character=character)
def about(self):
return render_template("about.html")
@staticmethod
def determine_character(answers):
traits = {
"brave": "Минск",
"wise": "Гейл",
"kind": "Карлах",
"cunning": "Астарион",
"strict": "Лаэзель",
"dark": "Шэдоухарт"
}
roles = {
"leader": "Минск",
"healer": "Хальсин",
"fighter": "Карлах",
"rogue": "Астарион",
"mage": "Гейл"
}
goals = {
"glory": "Минск",
"knowledge": "Гейл",
"protect": "Шэдоухарт",
"power": "Лаэзель"
}
rules = {
"strict": "Лаэзель",
"flexible": "Гейл",
"pragmatic": "Астарион",
"chaotic": "Шэдоухарт"
}
weapons = {
"sword": "Минск",
"staff": "Гейл",
"dagger": "Астарион",
"mace": "Карлах",
"bow": "Лаэзель"
}
places = {
"tavern": "Карлах",
"library": "Гейл",
"wilderness": "Хальсин",
"castle": "Лаэзель",
"dark_alley": "Шэдоухарт"
}
mood_fix = {
"training": "Лаэзель",
"reading": "Гейл",
"adventure": "Минск",
"meditation": "Шэдоухарт",
"drinking": "Карлах"
}
colors = {
"red": "Карлах",
"blue": "Гейл",
"green": "Хальсин",
"black": "Шэдоухарт",
"gold": "Лаэзель"
}
choices = [
traits.get(answers.get("question1")),
roles.get(answers.get("question2")),
goals.get(answers.get("question3")),
rules.get(answers.get("question4")),
weapons.get(answers.get("question5")),
places.get(answers.get("question6")),
mood_fix.get(answers.get("question7")),
colors.get(answers.get("question8"))
]
choices = [choice for choice in choices if choice is not None]
if not choices:
return {"name": "Неизвестно", "image": "unknown.jpg", "description": "Не удалось определить персонажа."}
most_common = max(set(choices), key=choices.count)
characters_info = {
"Минск": {"name": "Минск", "image": "minsk.jpg", "description": "Герой, идущий напролом с верным хомяком Бу"},
"Гейл": {"name": "Гейл", "image": "gale.jpg", "description": "Могущественный маг, жаждущий знаний и силы"},
"Карлах": {"name": "Карлах", "image": "karlach.jpg", "description": "Добрая, но грозная воительница"},
"Астарион": {"name": "Астарион", "image": "astarion.jpeg", "description": "Хитрый вампир, любящий свободу"},
"Лаэзель": {"name": "Лаэзель", "image": "laezel.jpg", "description": "Жесткая и бескомпромиссная гитянка-воительница"},
"Шэдоухарт": {"name": "Шэдоухарт", "image": "shadowheart.jpg", "description": "Таинственная жрица с темным прошлым"},
"Хальсин": {"name": "Хальсин", "image": "halsin.jpg", "description": "Мудрый друид, защитник природы."}
}
return characters_info.get(most_common, {"name": "Неизвестно", "image": "unknown.jpg", "description": "Не удалось определить персонажа."})
def run(self):
self.app.run(debug=True, host="0.0.0.0", port=5000)
if __name__ == "__main__":
app_instance = BaldursGateQuizApp()
app_instance.run()

View File

@ -1,29 +1,183 @@
body { body {
font-family: Arial, sans-serif; font-family: 'Arial', sans-serif;
background-color: #f4f4f4; background: url('../images/bg.jpeg') no-repeat center center fixed;
text-align: center; background-size: cover;
color: #fff;
margin: 0; margin: 0;
padding: 0; padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
}
.navbar {
width: 100%;
background: rgba(0, 0, 0, 0.8);
padding: 10px 0;
position: fixed;
top: 0;
left: 0;
text-align: center;
}
.navbar ul {
list-style: none;
padding: 0;
margin: 0;
display: flex;
justify-content: center;
gap: 20px;
}
.navbar ul li {
display: inline;
}
.navbar ul li a {
color: #fff;
text-decoration: none;
font-size: 18px;
padding: 10px 20px;
transition: 0.3s;
}
.navbar ul li a:hover {
background: #4CAF50;
border-radius: 5px;
}
.container {
text-align: center;
background: rgba(44, 44, 68, 0.9);
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
margin-top: 80px;
} }
h1 { h1 {
color: #333; margin-bottom: 20px;
font-size: 24px;
} }
form { /* Новые стили для блока с будущими статьями */
margin: 20px auto; .article-container {
background-color: rgba(0, 0, 0, 0.8); /* Темный фон */
color: #fff; /* Светлый текст */
padding: 20px; padding: 20px;
background: #fff; margin-top: 20px;
border-radius: 8px; border-radius: 8px;
width: 300px; border: none; /* Без обрамления, если не нужно */
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); text-align: center;
}
.article-container h2 {
margin-top: 0;
font-size: 22px;
}
.article-container p {
font-size: 16px;
}
/* Стили для тестовых вопросов */
.question {
margin: 20px 0;
font-size: 18px;
}
input[type="radio"] {
margin-right: 10px;
} }
button { button {
display: inline-block;
padding: 10px 20px; padding: 10px 20px;
background: #007bff; margin-top: 20px;
color: #fff; background-color: #4CAF50;
border: none; color: white;
border-radius: 4px; text-decoration: none;
cursor: pointer; border-radius: 5px;
font-size: 18px;
transition: 0.3s;
} }
button:hover {
background-color: #45a049;
}
.character-image {
width: 100%;
max-width: 600px;
height: auto;
border-radius: 10px;
margin-top: 20px;
box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}
.description {
font-size: 18px;
margin-top: 15px;
}
.button {
display: inline-block;
padding: 10px 20px;
margin-top: 20px;
background-color: #4CAF50;
color: white;
text-decoration: none;
border-radius: 5px;
font-size: 18px;
transition: 0.3s;
}
.button:hover {
background-color: #45a049;
}
.author-container {
background: rgba(44, 44, 68, 0.9); /* Темный фон для блока */
padding: 20px;
border-radius: 10px;
margin-top: 30px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
text-align: center;
}
.author-content {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
gap: 20px;
flex-wrap: wrap;
}
.author-photo {
flex: 0 0 150px; /* Фиксированная ширина для фото */
max-width: 150px;
}
.author-image {
width: 100%;
height: auto;
border-radius: 50%; /* Сделать изображение круглым */
border: 3px solid #fff; /* Белая обводка вокруг фото */
}
.author-bio {
max-width: 600px;
font-size: 18px;
color: #fff;
text-align: left;
}
.author-container h2 {
font-size: 24px;
margin-bottom: 20px;
color: #fff;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

BIN
site/static/images/bg.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

BIN
site/static/images/gale.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

BIN
site/static/images/uill.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

42
site/templates/about.html Normal file
View File

@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>О авторе</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
<nav class="navbar">
<ul>
<li><a href="/">Главная</a></li>
<li><a href="/tests">Тесты</a></li>
<li><a href="/about">Об авторе</a></li>
</ul>
</nav>
<div class="container">
<h1>О авторе</h1>
<div class="author-container">
<div class="author-content">
<div class="author-photo">
<img src="{{ url_for('static', filename='images/author.jpg') }}" alt="Фото автора" class="author-image">
</div>
<div class="author-bio">
<p>Привет! Я — Настя. Я создала этот тест, вдохновившись миром Baldur's Gate 3. Я увлекаюсь играми, программированием и созданием интерактивных приложений. Мой путь в разработке начался несколько лет назад, и с тех пор я продолжаю учиться и создавать интересные проекты.</p>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="footer-container">
<p>Контакты: <a href="mailto:author@example.com" style="color: white;">aazaytseva02@yandex.ru</a></p>
<p>Социальные сети:
<a href="https://vk.com/kikimora2222" target="_blank" style="color: white;">Vk</a> |
<a href="https://github.com/Foxyhhd" target="_blank" style="color: white;">GitHub</a>
</p>
</div>
</footer>
</body>
</html>

View File

@ -1,23 +1,28 @@
<!DOCKTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="ru">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Baldur's Gate Quiz</title> <title>Главная</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css')}}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
<body> </head>
<h1>Who Are you in Baldur's Gate?</h1> <body>
<form action="/result" method="POST"> <nav class="navbar">
<p>1. What trait best describes you?</p> <ul>
<input type="radio" name="question1" value="brave" id="brave"> <li><a href="/">Главная</a></li>
<label for="brave">Brave</label><br> <li><a href="/tests">Тесты</a></li>
<input type="radio" name="question1" value="wise" id="wise"> <li><a href="/about">Об авторе</a></li>
<label for="wise">Wise</label><br> </ul>
<input type="radio" name="question1" value="kind" id="kind"> </nav>
<label for="kind">Kind</label><br><br>
<button type="submit">Find Out</button> <div class="container">
</form> <h1 class="animate__animated animate__fadeInDown">Добро пожаловать на сайт Baldur's Gate 3</h1>
<div class="article-container animate__animated animate__fadeInUp">
<h2>Будущие статьи</h2>
<p>Здесь будут размещены статьи, посвященные героям и вселенной Baldur's Gate 3. Ожидайте интересные материалы!</p>
</div>
</div>
</body> </body>
</html> </html>

View File

@ -1,13 +1,28 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="ru">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Baldur's Gate Character</title> <title>Ваш персонаж из Baldur's Gate 3</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
</head> </head>
<body> <body>
<h1>You are {{ character }}!</h1> <nav class="navbar">
<a href="/">Try Again</a> <ul>
<li><a href="/">Главная</a></li>
<li><a href="/about">Об авторе</a></li>
<li><a href="/tests">Тесты</a></li>
</ul>
</nav>
<div class="container animate__animated animate__fadeInDown">
<h1>Вы — {{ character.name }}!</h1>
<img src="{{ url_for('static', filename='images/' + character.image) }}"
alt="{{ character.name }}"
class="character-image animate__animated animate__fadeIn">
<p class="description animate__animated animate__fadeInUp">{{ character.description }}</p>
<a href="/" class="button animate__animated animate__fadeIn">Попробовать снова</a>
</div>
</body> </body>
</html> </html>

110
site/templates/tests.html Normal file
View File

@ -0,0 +1,110 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Тест: Кто ты из Baldur's Gate 3?</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
</head>
<body>
<nav class="navbar">
<ul>
<li><a href="/">Главная</a></li>
<li><a href="/about">Об авторе</a></li>
<li><a href="/tests">Тесты</a></li>
</ul>
</nav>
<div class="container">
<h1 class="animate__animated animate__fadeInDown">Кто ты из Baldur's Gate 3?</h1>
<form action="/result" method="POST">
<div class="question animate__animated animate__fadeInLeft">
<p>1. Какая черта характера вам ближе всего?</p>
<input type="radio" name="question1" value="brave" id="brave">
<label for="brave">Смелость</label><br>
<input type="radio" name="question1" value="wise" id="wise">
<label for="wise">Мудрость</label><br>
<input type="radio" name="question1" value="kind" id="kind">
<label for="kind">Доброта</label><br>
<input type="radio" name="question1" value="cunning" id="cunning">
<label for="cunning">Хитрость</label><br>
<input type="radio" name="question1" value="strict" id="strict">
<label for="strict">Строгость</label><br>
<input type="radio" name="question1" value="dark" id="dark">
<label for="dark">Тьма</label><br>
</div>
<div class="question animate__animated animate__fadeInRight">
<p>2. Какую роль вы предпочитаете в команде?</p>
<input type="radio" name="question2" value="leader" id="leader">
<label for="leader">Лидер</label><br>
<input type="radio" name="question2" value="healer" id="healer">
<label for="healer">Целитель</label><br>
<input type="radio" name="question2" value="fighter" id="fighter">
<label for="fighter">Боец</label><br>
<input type="radio" name="question2" value="rogue" id="rogue">
<label for="rogue">Разбойник</label><br>
<input type="radio" name="question2" value="mage" id="mage">
<label for="mage">Маг</label><br>
</div>
<div class="question animate__animated animate__fadeInLeft">
<p>3. Какое оружие вам нравится больше всего?</p>
<input type="radio" name="question5" value="sword" id="sword">
<label for="sword">Меч</label><br>
<input type="radio" name="question5" value="staff" id="staff">
<label for="staff">Посох</label><br>
<input type="radio" name="question5" value="dagger" id="dagger">
<label for="dagger">Кинжал</label><br>
<input type="radio" name="question5" value="mace" id="mace">
<label for="mace">Булава</label><br>
<input type="radio" name="question5" value="bow" id="bow">
<label for="bow">Лук</label><br>
</div>
<div class="question animate__animated animate__fadeInRight">
<p>4. Где бы вы предпочли проводить досуг?</p>
<input type="radio" name="question6" value="tavern" id="tavern">
<label for="tavern">Таверна</label><br>
<input type="radio" name="question6" value="library" id="library">
<label for="library">Библиотека</label><br>
<input type="radio" name="question6" value="wilderness" id="wilderness">
<label for="wilderness">Дикая природа</label><br>
<input type="radio" name="question6" value="castle" id="castle">
<label for="castle">Замок</label><br>
<input type="radio" name="question6" value="dark_alley" id="dark_alley">
<label for="dark_alley">Темный переулок</label><br>
</div>
<div class="question animate__animated animate__fadeInLeft">
<p>5. Что вы делаете, если вам стало грустно?</p>
<input type="radio" name="question7" value="training" id="training">
<label for="training">Тренируюсь</label><br>
<input type="radio" name="question7" value="reading" id="reading">
<label for="reading">Читаю</label><br>
<input type="radio" name="question7" value="adventure" id="adventure">
<label for="adventure">Отправляюсь в приключение</label><br>
<input type="radio" name="question7" value="meditation" id="meditation">
<label for="meditation">Медитирую</label><br>
<input type="radio" name="question7" value="drinking" id="drinking">
<label for="drinking">Выпиваю</label><br>
</div>
<div class="question animate__animated animate__fadeInRight">
<p>6. Какой ваш любимый цвет?</p>
<input type="radio" name="question8" value="red" id="red">
<label for="red">Красный</label><br>
<input type="radio" name="question8" value="blue" id="blue">
<label for="blue">Синий</label><br>
<input type="radio" name="question8" value="green" id="green">
<label for="green">Зеленый</label><br>
<input type="radio" name="question8" value="black" id="black">
<label for="black">Черный</label><br>
<input type="radio" name="question8" value="gold" id="gold">
<label for="gold">Золотой</label><br>
</div>
<button type="submit" class="animate__animated animate__fadeInUp">Узнать результат</button>
</form>
</div>
</body>
</html>