-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from amine4567/feat/init_backend
feat: setup a devcontainer for python and initialize the flask backend
- Loading branch information
Showing
15 changed files
with
193 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,5 @@ | ||
FROM python:3.12 | ||
|
||
# Install python requirements | ||
COPY backend/requirements-combined.txt requirements-combined.txt | ||
RUN pip install -r requirements-combined.txt |
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,33 @@ | ||
{ | ||
"name": "retro_olympics_webapp", | ||
"dockerComposeFile": "docker-compose.yml", | ||
"workspaceFolder": "/workspace", | ||
"service": "webapp", | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.black-formatter", | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": "always" | ||
} | ||
}, | ||
"isort.args": ["--profile", "black"], | ||
"ruff.nativeServer": true | ||
}, | ||
"extensions": [ | ||
"eamodio.gitlens", | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
"ms-python.black-formatter", | ||
"ms-python.isort", | ||
"charliermarsh.ruff" | ||
] | ||
} | ||
}, | ||
"remoteUser": "root", | ||
"remoteEnv": { | ||
"PYTHONPATH": "/workspace/backend/src" | ||
} | ||
} |
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 @@ | ||
version: "3.8" | ||
services: | ||
webapp: | ||
build: | ||
context: .. | ||
dockerfile: .devcontainer/Dockerfile | ||
entrypoint: ["tail", "-f", "/dev/null"] | ||
volumes: | ||
- ..:/workspace | ||
postgres: | ||
image: "postgres:16" | ||
environment: | ||
POSTGRES_HOST_AUTH_METHOD: trust |
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 |
---|---|---|
|
@@ -18,3 +18,6 @@ build | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
# Python | ||
*.pyc |
Empty file.
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,57 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.12 | ||
# by the following command: | ||
# | ||
# pip-compile --output-file=backend/requirements-combined.txt backend/requirements-dev.in backend/requirements.in | ||
# | ||
black==24.4.2 | ||
# via -r backend/requirements-dev.in | ||
blinker==1.8.2 | ||
# via flask | ||
build==1.2.1 | ||
# via pip-tools | ||
click==8.1.7 | ||
# via | ||
# black | ||
# flask | ||
# pip-tools | ||
flask==3.0.3 | ||
# via -r backend/requirements.in | ||
invoke==2.2.0 | ||
# via -r backend/requirements-dev.in | ||
isort==5.13.2 | ||
# via -r backend/requirements-dev.in | ||
itsdangerous==2.2.0 | ||
# via flask | ||
jinja2==3.1.4 | ||
# via flask | ||
markupsafe==2.1.5 | ||
# via | ||
# jinja2 | ||
# werkzeug | ||
mypy-extensions==1.0.0 | ||
# via black | ||
packaging==24.1 | ||
# via | ||
# black | ||
# build | ||
pathspec==0.12.1 | ||
# via black | ||
pip-tools==7.4.1 | ||
# via -r backend/requirements-dev.in | ||
platformdirs==4.2.2 | ||
# via black | ||
pyproject-hooks==1.1.0 | ||
# via | ||
# build | ||
# pip-tools | ||
ruff==0.4.9 | ||
# via -r backend/requirements-dev.in | ||
werkzeug==3.0.3 | ||
# via flask | ||
wheel==0.43.0 | ||
# via pip-tools | ||
|
||
# The following packages are considered to be unsafe in a requirements file: | ||
# pip | ||
# setuptools |
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 @@ | ||
black==24.4.2 | ||
invoke==2.2.0 | ||
pip-tools==7.4.1 | ||
isort==5.13.2 | ||
ruff==0.4.9 |
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 @@ | ||
Flask==3.0.3 |
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 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.12 | ||
# by the following command: | ||
# | ||
# pip-compile backend/requirements.in | ||
# | ||
blinker==1.8.2 | ||
# via flask | ||
click==8.1.7 | ||
# via flask | ||
flask==3.0.3 | ||
# via -r backend/requirements.in | ||
itsdangerous==2.2.0 | ||
# via flask | ||
jinja2==3.1.4 | ||
# via flask | ||
markupsafe==2.1.5 | ||
# via | ||
# jinja2 | ||
# werkzeug | ||
werkzeug==3.0.3 | ||
# via flask |
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,3 @@ | ||
from .main import get_api | ||
|
||
__all__ = ["get_api"] |
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,3 @@ | ||
from .controller import hello_api | ||
|
||
__all__ = ["hello_api"] |
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,10 @@ | ||
from flask import Blueprint, jsonify | ||
|
||
from api.consts import COMMON_API_PREFIX | ||
|
||
hello_api = Blueprint("hello_api", __name__, url_prefix=COMMON_API_PREFIX + "/hello") | ||
|
||
|
||
@hello_api.route("/", methods=["GET"]) | ||
def get_collections(): | ||
return jsonify({"message": "Hello World ! From the retro olympics backend !"}), 200 |
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 @@ | ||
COMMON_API_PREFIX = "/api/v1" |
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,15 @@ | ||
from flask import Flask | ||
|
||
from api.components.hello import hello_api | ||
|
||
api: Flask | None = None | ||
|
||
|
||
def get_api() -> Flask: | ||
global api | ||
if api is None: | ||
api = Flask(__name__) | ||
|
||
api.register_blueprint(hello_api) | ||
|
||
return api |
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 @@ | ||
from invoke import task | ||
|
||
from api import get_api | ||
|
||
|
||
# Python reqs | ||
@task | ||
def update_app_reqs(c): | ||
c.run("pip-compile backend/requirements.in") | ||
|
||
|
||
@task | ||
def update_combined_reqs(c): | ||
c.run( | ||
"pip-compile backend/requirements.in backend/requirements-dev.in -o backend/requirements-combined.txt" | ||
) | ||
|
||
|
||
# Run | ||
@task | ||
def run_back(c): | ||
get_api().run() |