Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pavel intalov #25

Open
wants to merge 13 commits into
base: Pavel_Intalov
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.9
python-version: 3.10

- name: Install dependencies with pipenv
run: |
Expand Down
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ verify_ssl = true
name = "pypi"

[packages]
flask = "*"

[dev-packages]
mypy = "*"
flake8 = "*"

[requires]
python_version = "3.9"
python_version = "3.10"
149 changes: 122 additions & 27 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Tprogramming_2022_zaochn

### Установка виртуального окружения
Инталов Павел Иванович

```shell
pip install pipenv
Expand Down
75 changes: 75 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from unicodedata import name
from flask import Flask, render_template
from datetime import datetime

from flask import request

app = Flask(__name__)

@app.route("/")
def index():
now = datetime.now()
user = {'username': 'Павлик'}
if now.hour > 5 and now.hour < 12:
time_of_day = "morning"
elif now.hour >= 12 and now.hour < 17:
time_of_day = "day"
elif now.hour >= 17 and now.hour < 23:
time_of_day = "evening"
items = ["один", "два", "три", "четыре", "пять"]

return render_template('index.html', title='home', user=user, time_of_day=time_of_day, items=items, )

@app.route("/simple")
def simple():
a = request.args.get("a", default=5,type=float)
b = request.args.get("b", default=10)
return f"<h1>{a}+{b}={a+b}</h1>"

@app.route("/Hello")
def hello_world():
now = datetime.now()
return f"<p>О ПРЕКРАСНЫЙ СУП НАВАРИЛИ! {now}</p>"

@app.route("/styled")
def hello_styles():
now = datetime.now()
return f"""
<h1>Заголовушка</h1>
<p>О ПРЕКРАСНЫЙ СУП НАВАРИЛИ!</p>
<p>Времы судного дня {now}</p>
"""

@app.route('/calc', methods=['GET', 'POST'])
def calc():
a = request.form.get("a",default=0,type=float)
b = request.form.get("b",default=0,type=float)
return render_template("calc.html", a=a, b=b, result=a+b)

import cat

cats = {
"vasya": cat.Cat("vasya", 3),
"barsik": cat.Cat("barsik", 3),
"murzik": cat.Cat("murzik", 3),
}

@app.route('/cats')
def list_cats():
return render_template("cats.html", cats = cats)

@app.route("/cats/<name>")
def show_cat(name):
cat = cats[name]
return render_template("cat.html", cat = cat)

@app.route("/cats/new", methods=["GET", "POST"])
def create_cat():
name = request.form.get("name",default="untitled")
age = request.form.get("age",default=0,type=float)

new_cat = cat.Cat(name, age)

cats[new_cat.name] = new_cat

return render_template("new_cat.html")
5 changes: 5 additions & 0 deletions cat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Cat:
def __init__(self, name, age, img=""):
self.name = name
self.age = age
self.img = img
22 changes: 22 additions & 0 deletions lab1/labIntal1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import math
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не забывайцте добавлять расширение файла - .py

from re import X
from tkinter import Y
Comment on lines +2 to +3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот эти 2 импорта не нужны

def calc(x: float) float:
return (math.asin(x)*4+math.acos(x)*6)*1/7
def task_a(xn,xkm,dx):
x=xn
y=[]
while x <=xk:
y_tmp=calc(x)
y.append(y_tmp)
x += dx
return (y)
def task_b(x):
y=[]
for item in x:
y.append(calc(item))
if __name__ = "__main__":
y= task_a(0.22,0.92,0.14)
print (y)
y=task_b([0.1,0.35,0.4,0.55,0.6])
print (X)
Binary file added static/fon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/ххх.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions templates/base_cat.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<title>Cat</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
</head>
<body>
{% block main %}{% endblock %}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
</body>
</html>
15 changes: 15 additions & 0 deletions templates/calc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<head>
<title>Calculator</title>
</head>
<body style="background-image:url(static/fon.jpg)">
<h1>Calculator</h1>
<form action="" method="POST">
<input type="number" value="{{a}}" name="a"/>
+
<input type="number" value="{{b}}" name="b"/>
<button type="submit">Calc</button>
</form>
<p>Result = {{result}}</p>
</body>
</html>
14 changes: 14 additions & 0 deletions templates/cat.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends "base_cat.html" %}
{% block main %}
<h1>{{cat.name}}:</h1>
<ul>
<li>
Возраст: {{ cat.age }}
</li>
{% if cat.img %}
<li>
<img src="{{cat.img}}"/>
</li>
{% endif %}
</ul>
{% endblock %}
14 changes: 14 additions & 0 deletions templates/cats.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends "base_cat.html" %}
{% block main %}
<h1>Киски:</h1>
<ul>
{% for key, cat in cats.items() %}
<li>
<a href="{{'cats/%s' % cat.name}}"> {{ cat.name }}</a>
</li>
{% endfor %}
</ul>

<a href="cats/new" class="btn btn-primary" role="button">Добавить</a>

{% endblock %}
24 changes: 24 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Отче наш, иже еси в моем PC. Да святится имя и расширение Твое. Да придет прерывание Твое и да будет воля твоя. BASIC наш насущный дай нам; И прости нам дизассемблеры и антивирусы наши, как Копиpайты прощаем мы. И не введи нас в Exception Error, но избавь нас от зависания, ибо Твое есть адpессное пространство, порты и регистры.
<html>
<head>
<title>{{ title }} - Microblog</title>
</head>
<body style="background-image:url(static/fon.jpg)">
{% if time_of_day == "morning" %}
<h1>Да будет с тобой святой машинный код 1, {{ user.username }}!</h1>
<img src="static/xxx.jpg" alt="икона" width="100" height="80" />
{% elif time_of_day == "day" %}
<h1>Да будет с тобой святой машинный код 2, {{ user.username }}!</h1>
<p><img src="static/ххх.jpg" alt="икона" width="100" height="80"></p>
{% elif time_of_day == "evening" %}
<h1>Да будет с тобой святой машинный код 3, {{ user.username }}!</h1>
{% else %}
<h1>Да будет с тобой святой машинный код 4, {{ user.username }}!</h1>
{% endif %}
<ul>
{% for element in items %}
<li>{{element}}</li>
{% endfor %}
</ul>
</body>
</html>
Loading