From 4ef44fc2edbb86017fc1a660f957a9bf7b0bac6d Mon Sep 17 00:00:00 2001 From: akula Date: Tue, 3 Dec 2024 12:29:43 +0300 Subject: [PATCH] 1 --- .woodpecker/publish.yml | 18 +++++++++++++ Dockerfile | 8 ++++++ app/__init__.py | 18 +++++++++++++ app/__pycache__/__init__.cpython-39.pyc | Bin 0 -> 592 bytes app/__pycache__/models.cpython-39.pyc | Bin 0 -> 460 bytes app/__pycache__/routes.cpython-39.pyc | Bin 0 -> 1452 bytes app/models.py | 6 +++++ app/routes.py | 34 ++++++++++++++++++++++++ app/static/style.css | 21 +++++++++++++++ app/templates/base.html | 14 ++++++++++ app/templates/index.html | 21 +++++++++++++++ docker-compose.yml | 10 +++++++ instance/todo.db | Bin 0 -> 8192 bytes requirements.txt | 2 ++ run.py | 6 +++++ 15 files changed, 158 insertions(+) create mode 100644 .woodpecker/publish.yml create mode 100644 Dockerfile create mode 100644 app/__init__.py create mode 100644 app/__pycache__/__init__.cpython-39.pyc create mode 100644 app/__pycache__/models.cpython-39.pyc create mode 100644 app/__pycache__/routes.cpython-39.pyc create mode 100644 app/models.py create mode 100644 app/routes.py create mode 100644 app/static/style.css create mode 100644 app/templates/base.html create mode 100644 app/templates/index.html create mode 100644 docker-compose.yml create mode 100644 instance/todo.db create mode 100644 requirements.txt create mode 100644 run.py diff --git a/.woodpecker/publish.yml b/.woodpecker/publish.yml new file mode 100644 index 0000000..5af673c --- /dev/null +++ b/.woodpecker/publish.yml @@ -0,0 +1,18 @@ +--- + +when: + branch: main + event: push + +steps: + publish: + image: woodpeckerci/plugin-docker-buildx + settings: + dockerfile: Dockerfile + auto_tag: true + tag: latest + repo: akulovsergei/test-app + username: akulovsergei + password: + from_secret: docker_token + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6dcec48 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM python:3.9-slim + +WORKDIR /app +COPY . . + +RUN pip install --no-cache-dir -r requirements.txt + +CMD ["python", "run.py"] diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000..3f43a08 --- /dev/null +++ b/app/__init__.py @@ -0,0 +1,18 @@ +from flask import Flask +from flask_sqlalchemy import SQLAlchemy + +db = SQLAlchemy() + +def create_app(): + app = Flask(__name__) + app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///todo.db" + app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False + + db.init_app(app) + + # Импорт и регистрация маршрутов + with app.app_context(): + from . import routes + db.create_all() + + return app diff --git a/app/__pycache__/__init__.cpython-39.pyc b/app/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..36f72a550c547bdc7aa81a97935f108607a63855 GIT binary patch literal 592 zcmYjOO>Yx15FOjQn`N6yK|<<{6GB=J4O~%#ST>D_NK>^*1@*;RVy6VWAMCnPgOXFY z^9MLIM~?iRz4p|0FHoE*x0B-GO*C=jYqgT%mBuJtm zC7ci&Q%zIG83DyMz#Yk?^BuS=-3f%=9o9ogYImTM>I(+J_>A;s=e_xA)o9dbWajRA^-k|cL;jjeWI`wp$pHhdS;}M1*(C!3&JzO%`C2?W zu>Dsm*4>h@hoD$<1Ya?uN++PNDIGfdc=L= zeF$h(Xx+IgH*;DxC`^(nvy~g%?jC6P1&Lu+YpoUpIPBaFtcKLSsb&)}K`-$yU~@l1ifu&hlKN%4~0$r-jA} z;fj0_1UETim$P#_Gw;3Gy-~ND3OxV3{p0A1FT^KWtUm!3 zzhcxMF)5*BAxfFa(#yQk&-^mTf-=lPDU_%DA}Zr7W;-a7vX!-93l$k^|?ZuHo?cy5Z}VP!r` z3YE@NuP_HM5s&}&cy5ry4o9=uBJ5klj;Y4_LxImQY7$II;P3{ETfgg~s2=Y!klnoA zeOH+``Sj@FxiD?)TTNfL`$*2iRC83=o4t1dRZ1wShe>#*i}|bUUn)+8sU{b{0mF)k zJoV1Rv9P|9OEl(#2RQy(KMuf5l{EY771E!fq)z_bwLLP%oXJAYIZ#)rdf(zF8E z;Z2-?P%us5rP5r-Y7z8DO1a?qpD$iQuej9qb*1V{IEex!W}N#l8k|a=$z!n;=85$g zt2~xAn1rX%5^tnnJ3bSz65CS#i98{3g8}g8w$MFkh&03KrG}Jn0XkVa|43WrW=KL8 z*SfCrY6^;g8jY*6%&iG2Hp0~NIFC!F`rVL}xyn637{A!Y?waHfUPlHpl^qOo59`HF zU+F?y-QUlr_7}=B%+") +def delete_task(task_id): + task = Task.query.get_or_404(task_id) + db.session.delete(task) + db.session.commit() + return redirect(url_for("index")) + +@app.route("/complete/") +def complete_task(task_id): + task = Task.query.get_or_404(task_id) + task.completed = not task.completed + db.session.commit() + return redirect(url_for("index")) + diff --git a/app/static/style.css b/app/static/style.css new file mode 100644 index 0000000..9edeb21 --- /dev/null +++ b/app/static/style.css @@ -0,0 +1,21 @@ +body { + font-family: Arial, sans-serif; + margin: 20px; +} + +h1 { + color: #333; +} + +ul { + list-style-type: none; + padding: 0; +} + +li { + margin: 5px 0; +} + +form { + margin-bottom: 20px; +} diff --git a/app/templates/base.html b/app/templates/base.html new file mode 100644 index 0000000..7b79284 --- /dev/null +++ b/app/templates/base.html @@ -0,0 +1,14 @@ + + + + + + To-Do List + + + +
+ {% block content %}{% endblock %} +
+ + diff --git a/app/templates/index.html b/app/templates/index.html new file mode 100644 index 0000000..72db36b --- /dev/null +++ b/app/templates/index.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} + +{% block content %} +

To-Do List for DEVOPS

+
+ + +
+ +{% endblock %} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9bb3aad --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +--- +services: + web: + build: . + ports: + - "5000:5000" + volumes: + - .:/app + environment: + - FLASK_ENV=development diff --git a/instance/todo.db b/instance/todo.db new file mode 100644 index 0000000000000000000000000000000000000000..94ac226cb9dfe5d08d38957dbeedd29d5ea62720 GIT binary patch literal 8192 zcmeIuy-ve05C`yc3ABz>+<~fMGg~VG;^PHyTZ>eL6hZ)X3{6NQS{2%e%zcqQ08hcp zBe3%b>^MUunAlkOpYCLzPqwVz)uo$evAmzoCSfLzsYZ;^iIhZCHB~aT3T8IesxfQP z{}xr+AF|>hCZ5S80s;_#00bZa0SG_<0uX=z1R(H_1QumhZq(~+@sx#k<2VcF4@H$a zzE**jfoi*27ALZ4^E8q@FVLsjmtH@R-nHxQN}FeCHjd?u@;i?5n}KRO cMx!{~ELpTunJ1%Jo{aJ^;mnM9o+L^B1^FRG1poj5 literal 0 HcmV?d00001 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..de8a130 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +flask +flask_sqlalchemy diff --git a/run.py b/run.py new file mode 100644 index 0000000..f61366d --- /dev/null +++ b/run.py @@ -0,0 +1,6 @@ +from app import create_app + +app = create_app() + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=5000, debug=True)