-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e04e8aa
Showing
16 changed files
with
574 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
docker/ | ||
.github/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Python checks | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.11 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install poetry | ||
poetry install | ||
- name: ruff check | ||
run: poetry run ruff check | ||
- name: mypy check | ||
run: poetry run mypy challenge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.vscode/ | ||
.ruff_cache/ | ||
.mypy_cache/ | ||
**/__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# SUCSS Challenge Template | ||
|
||
This template repository contains all the required files to start a simple challenge. | ||
|
||
## Setup | ||
|
||
Ensure you have python poetry installed - this is used to install a virtualenv and manage dependencies | ||
|
||
``` | ||
pip install --upgrade pip | ||
pip3 install -u poetry | ||
poetry install --no-root | ||
``` | ||
|
||
## Running in development | ||
|
||
Flask comes with a development server built in. To use it, run | ||
``` | ||
poetry run flask -A challenge run | ||
``` | ||
|
||
## Running in production | ||
|
||
``` | ||
poetry run gunicorn 'challenge:app' | ||
``` | ||
|
||
## Running with docker | ||
|
||
``` | ||
docker-compose -p "<project name>" -f "docker/compose.yaml" up --build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from flask import Flask | ||
|
||
app = Flask(__name__) | ||
# app.config.from_object('config') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
body { | ||
margin: 0; | ||
font-family: sans-serif; | ||
} | ||
|
||
h1 { | ||
width: 100%; | ||
background-color: #000000; | ||
color: #ffffff; | ||
margin: 0; | ||
padding: 5px 20px; | ||
} | ||
|
||
.container { | ||
width: 800px; | ||
margin: 20px auto; | ||
background-color: rgba(0,0,0,0.1); | ||
padding: 15px; | ||
} | ||
|
||
h2 { | ||
text-align: center; | ||
} | ||
|
||
form { | ||
width: 100%; | ||
} | ||
|
||
input { | ||
width: 100%; | ||
} | ||
|
||
button { | ||
margin-top: 10px; | ||
display: block; | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
|
||
.invalid-feedback { | ||
color: #ff0000; | ||
text-align: center; | ||
margin-top: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% extends 'layout.html' %} | ||
|
||
{% block content %} | ||
<h1>Challenge 2</h1> | ||
<p>This is an example using a flask View to render a template</p> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% extends 'layout.html' %} | ||
|
||
{% block content %} | ||
<h1>Home</h1> | ||
<p>Welcome to the home page</p> | ||
<div id="challenges"> | ||
<h2>Challenges</h2> | ||
<ul> | ||
<li><a href="/1/">Example Challenge 1</a></li> | ||
<li><a href="/2/">Example Challenge 2</a></li> | ||
</ul> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>{%if title%}{{title}}{%else%}SUCSS Challenge{%endif%}</title> | ||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}" /> | ||
</head> | ||
<body> | ||
<div id="content"> | ||
{% block content %}{% endblock content %} | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from flask import render_template | ||
|
||
from challenge import app | ||
|
||
from . import ( | ||
challenge_1, # noqa: F401 | ||
challenge_2, # noqa: F401 | ||
) | ||
|
||
|
||
@app.route("/", methods=["GET"]) | ||
def index() -> str: | ||
return render_template("index.html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from flask import views | ||
|
||
from challenge import app | ||
|
||
|
||
class Challenge1View(views.MethodView): | ||
def get(self) -> str: | ||
return "Challenge 1 GET" | ||
|
||
def post(self) -> str: | ||
return "Challenge 1 POST" | ||
|
||
|
||
app.add_url_rule("/1/", view_func=Challenge1View.as_view("challenge1")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from flask import render_template, views | ||
|
||
from challenge import app | ||
|
||
|
||
class Challenge2View(views.View): | ||
template_name = "challenge2.html" | ||
|
||
def dispatch_request(self) -> str: | ||
return render_template(self.template_name) | ||
|
||
|
||
app.add_url_rule("/2/", view_func=Challenge2View.as_view("challenge2")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM python:3.10 | ||
|
||
RUN pip install poetry | ||
|
||
COPY pyproject.toml /app/pyproject.toml | ||
COPY poetry.lock /app/poetry.lock | ||
|
||
WORKDIR /app | ||
|
||
RUN poetry install --no-dev | ||
|
||
COPY . /app | ||
|
||
CMD ["poetry", "run", "gunicorn", "-b", "0.0.0.0", "challenge:app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: '3' | ||
services: | ||
app: | ||
build: | ||
context: ../ | ||
dockerfile: docker/Dockerfile | ||
ports: | ||
- "8000:8000" |
Oops, something went wrong.