Skip to content

Commit 7f2a4c9

Browse files
committed
Initial commit
0 parents  commit 7f2a4c9

79 files changed

Lines changed: 2309 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.do/deploy.template.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
spec:
2+
alerts:
3+
- rule: DEPLOYMENT_FAILED
4+
- rule: DOMAIN_FAILED
5+
name: pythonvilag-website
6+
region: fra
7+
features:
8+
- buildpack-stack=ubuntu-22
9+
ingress:
10+
rules:
11+
- component:
12+
name: pythonvilag-website
13+
match:
14+
path:
15+
prefix: /
16+
services:
17+
- name: pythonvilag-website
18+
environment_slug: python
19+
instance_count: 1
20+
instance_size_slug: basic-xxs
21+
run_command: gunicorn --config gunicorn_config.py
22+
source_dir: /
23+
http_port: 5000
24+
github:
25+
repo: PythonVilag/pythonvilag-website
26+
branch: main
27+
deploy_on_push: true
28+
envs:
29+
- key: FLASK_DEBUG
30+
scope: RUN_AND_BUILD_TIME
31+
type: SECRET
32+
value:
33+
- key: PV_SECRET_KEY
34+
scope: RUN_AND_BUILD_TIME
35+
type: SECRET
36+
value:
37+
- key: PRIVATE_LECTURE_AUTOMATION
38+
scope: RUN_AND_BUILD_TIME
39+
type: SECRET
40+
value:
41+
- key: CHECKMARK
42+
scope: RUN_AND_BUILD_TIME
43+
type: SECRET
44+
value:
45+
- key: EMAIL_ADDRESS
46+
scope: RUN_AND_BUILD_TIME
47+
type: SECRET
48+
value:
49+
- key: EMAIL_PASSWORD
50+
scope: RUN_AND_BUILD_TIME
51+
type: SECRET
52+
value:
53+
- key: HOST
54+
scope: RUN_AND_BUILD_TIME
55+
type: SECRET
56+
value:
57+
- key: PORT
58+
scope: RUN_AND_BUILD_TIME
59+
type: SECRET
60+
value:

.github/workflows/main.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: pythonvilag ci
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
run-tests:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Check out the codebase.
16+
uses: actions/checkout@v3
17+
18+
- name: Set up Python.
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: '3.11'
22+
23+
- name: Upgrade pip.
24+
run: >
25+
python -m pip install --upgrade pip
26+
27+
- name: Install dependencies.
28+
run: >
29+
pip install tox tox-gh
30+
31+
- name: Run tests with tox.
32+
run: >
33+
tox

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Project
2+
src/pythonvilag_website/static/uploads/*
3+
4+
# System
5+
.DS_Store
6+
7+
# Distribution / Packaging
8+
build/
9+
dist/
10+
eggs/
11+
.eggs/
12+
sdist/
13+
wheels/
14+
*.egg-info/
15+
*.egg
16+
17+
# Unit test / Coverage reports
18+
.tox/
19+
.coverage
20+
21+
# Environments
22+
.env
23+
.venv
24+
env/
25+
venv/
26+
27+
# Python
28+
__pycache__/
29+
.ipynb_checkpoints
30+
*.egg-info/
31+
*.log
32+
*.py[cod]
33+
*$py.class
34+
35+
# IDE
36+
.idea/
37+
.vscode/

.pre-commit-config.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
4+
exclude: "test/db_setup.py|"
5+
6+
# pre-commit
7+
repos:
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v4.5.0
10+
hooks:
11+
- id: check-added-large-files
12+
args: [--maxkb=2000]
13+
- id: check-docstring-first
14+
- id: check-merge-conflict
15+
- id: check-toml
16+
- id: check-yaml
17+
- id: detect-private-key
18+
- id: end-of-file-fixer
19+
- id: name-tests-test
20+
- id: trailing-whitespace
21+
22+
# ruff
23+
- repo: https://github.com/astral-sh/ruff-pre-commit
24+
rev: v0.2.1
25+
hooks:
26+
- id: ruff
27+
args: [--line-length=120]
28+
- id: ruff-format

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Daniel Mizsak
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn --config gunicorn_config.py src.run:app

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## <div align="center"> ⚪️🔵🔴🟢 pythonvilag-website</div>
2+
3+
<div align="center">
4+
<a href="https://github.com/PythonVilag/pythonvilag-website/actions/workflows/main.yml" target="_blank"><img src="https://github.com/PythonVilag/pythonvilag-website/actions/workflows/main.yml/badge.svg" alt="build status"></a>
5+
<a href="https://results.pre-commit.ci/latest/github/PythonVilag/pythonvilag-website/main" target="_blank"><img src="https://results.pre-commit.ci/badge/github/PythonVilag/pythonvilag-website/main.svg" alt="pre-commit.ci status"></a>
6+
<a href="https://img.shields.io/github/license/PythonVilag/pythonvilag-website" target="_blank"><img src="https://img.shields.io/github/license/PythonVilag/pythonvilag-website" alt="license"></a>
7+
</div>
8+
9+
10+
## Overview
11+
Source code that powers the <a href="https://pythonvilag.hu/" target="_blank">Python Világ</a> website.
12+
<br><br>
13+
14+
## Deployment
15+
Currently I am hosting this website on [digitalocean](https://www.digitalocean.com/).
16+
The following link can be used to deploy the website.
17+
18+
<a href="https://cloud.digitalocean.com/apps/new?repo=https://github.com/PythonVilag/pythonvilag-website/tree/main&refcode=f2cb42a82894" target="_blank">
19+
<img src="https://www.deploytodo.com/do-btn-white.svg" alt="deploy">
20+
</a>

gunicorn_config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""
2+
Deploying the application with Gunicorn.
3+
4+
@author "Daniel Mizsak" <info@pythonvilag.hu>
5+
"""
6+
7+
bind = "0.0.0.0:5000"
8+
worker_tmp_dir = "/dev/shm" # noqa: S108
9+
workers = 2
10+
wsgi_app = "src.run:app"

passenger_wsgi.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""
2+
Deploying the application with Passenger WSGI.
3+
4+
@author "Daniel Mizsak" <info@pythonvilag.hu>
5+
"""
6+
7+
import imp
8+
9+
wsgi = imp.load_source("wsgi", "src/run.py")
10+
application = wsgi.app

pyproject.toml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Build System
2+
[build-system]
3+
requires = ["hatchling"]
4+
build-backend = "hatchling.build"
5+
6+
# Project Metadata
7+
[project]
8+
name = "pythonvilag_website"
9+
version = "0.0.1"
10+
description = "Pythonvilag website."
11+
readme = "README.md"
12+
requires-python = ">=3.11"
13+
license = { file = "LICENSE" }
14+
authors = [{ name = "Daniel Mizsak", email = "info@pythonvilag.hu" }]
15+
keywords = ["website", "tutorial", "flask", "pythonvilag"]
16+
classifiers = [
17+
"License :: OSI Approved :: MIT License",
18+
"Programming Language :: Python :: 3.11",
19+
"Programming Language :: Python :: 3.12",
20+
]
21+
dependencies = [
22+
"Flask-SQLAlchemy==3.1.1",
23+
"Flask-WTF==1.2.1",
24+
"Flask==3.0.2",
25+
"gunicorn==21.2.0",
26+
"itsdangerous==2.1.2",
27+
"python-dotenv==1.0.1",
28+
"SQLAlchemy==2.0.27",
29+
"Werkzeug==3.0.1",
30+
# Self maintained
31+
# "private-lecture-automation==0.2.0",
32+
# "checkmark==0.1.0",
33+
]
34+
35+
[project.optional-dependencies]
36+
dev = ["mypy", "pre-commit", "pytest-cov", "pytest", "ruff", "tox"]
37+
38+
[project.urls]
39+
Repository = "https://github.com/PythonVilag/pythonvilag-website/"
40+
Homepage = "https://pythonvilag.hu/"
41+
42+
# Tools
43+
# MyPy
44+
[tool.mypy]
45+
exclude = ["^tests/"]
46+
ignore_missing_imports = true
47+
pretty = true
48+
show_column_numbers = true
49+
show_error_context = true
50+
strict = true
51+
warn_unreachable = true
52+
warn_unused_ignores = true
53+
54+
# Pytest
55+
[tool.pytest.ini_options]
56+
addopts = "--cov=pythonvilag_website"
57+
testpaths = ["tests"]
58+
59+
# Ruff
60+
[tool.ruff]
61+
select = ["ALL"]
62+
line-length = 120
63+
src = ["src", "tests"]
64+
ignore = [
65+
"D203", # one-blank-line-before-class
66+
"D212", # multi-line-summary-first-line
67+
"FIX", # flake8-fixme
68+
"INP", # flake8-no-pep420
69+
"S104", # hardcoded-bind-all-interfaces
70+
"TD002", # missing-todo-author
71+
"TD003", # missing-todo-link
72+
]
73+
[tool.ruff.per-file-ignores]
74+
"**/__init__.py" = [
75+
"D104", # undocumented-public-package
76+
]
77+
"tests/**/*.py" = [
78+
"ANN001", # missing-type-function-argument
79+
"ANN201", # missing-return-type-undocumented-public-function
80+
"D", # pydocstyle
81+
"E501", # line-too-long
82+
"PLR2004", # magic-value-comparison
83+
"S101", # assert
84+
]
85+
[tool.ruff.pydocstyle]
86+
convention = "google"
87+
88+
# Tox
89+
[tool.tox]
90+
legacy_tox_ini = """
91+
[tox]
92+
envlist = py311,mypy,ruff
93+
skip-missing-interpreters = true
94+
95+
[gh]
96+
python =
97+
3.11 = py311, mypy, ruff
98+
99+
[testenv]
100+
setenv =
101+
PV_SECRET_KEY = {env:PV_SECRET_KEY:SECRET}
102+
FLASK_DEBUG = {env:FLASK_DEBUG:False}
103+
PRIVATE_LECTURE_AUTOMATION = {env:PRIVATE_LECTURE_AUTOMATION:False}
104+
CHECKMARK = {env:CHECKMARK:False}
105+
deps =
106+
pytest
107+
pytest-cov
108+
commands = pytest {posargs:tests}
109+
110+
[testenv:mypy]
111+
basepython = python3.11
112+
deps = mypy
113+
commands = mypy .
114+
115+
[testenv:ruff]
116+
basepython = python3.11
117+
deps = ruff
118+
commands = ruff check .
119+
"""

0 commit comments

Comments
 (0)