Go to file
Frank Lanitz 35cafe1780
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
auth.py: Make usage of exceptions instead of if-else-blocks
2021-06-21 16:01:29 +02:00
data add Dockerfile 2021-06-14 21:56:20 +02:00
ki auth.py: Make usage of exceptions instead of if-else-blocks 2021-06-21 16:01:29 +02:00
migrations extract profile 2021-06-20 19:25:27 +02:00
.drone.yml add initial .drone.yml 2021-06-15 18:45:45 +02:00
.editorconfig add editorconfig 2021-06-14 22:39:33 +02:00
.flake8 add flake8 2021-06-15 18:08:57 +02:00
.gitignore start python backend 2021-06-06 22:25:10 +02:00
Dockerfile add Dockerfile 2021-06-14 21:56:20 +02:00
LICENSE Initial commit 2021-05-31 18:45:15 +02:00
Pipfile add flake8 2021-06-15 18:08:57 +02:00
Pipfile.lock add flake8 2021-06-15 18:08:57 +02:00
README.md implement update profile endpoint 2021-06-20 20:13:19 +02:00
app.py add flake8 2021-06-15 18:08:57 +02:00
drone.yml add initial .drone.yml 2021-06-15 18:45:45 +02:00
env.dev implement login 2021-06-12 13:24:26 +02:00
run_prod.py add production script 2021-06-12 10:06:40 +02:00

README.md

Kompetenzinventar Backend

Build Status

Entwicklung

Abhängigkeiten

Entwicklungsumgebung aufbauen und starten

Ggf. vorher aufräumen

rm data/ki.sqlite
cp env.dev .env
pipenv install --dev
pipenv shell
export FLASK_APP=app.py
flask db upgrade
flask seed
flask run

http://localhost:5000/

Tests ausführen

python -m unittest discover ki

Linting

flake8

Testbenutzer

Für ein Login ohne LDAP werden die Benutzer aus der auth.yml benutzt.

Beispiel-Requests

Beispiele brauchen curl und jq.

curl -s \
    -D "/dev/stderr" \
    http://localhost:5000/skills?search=ph | jq
curl -s \
    -D "/dev/stderr" \
    http://localhost:5000/languages?search=fr | jq
curl -s \
    -D "/dev/stderr" \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"username": "peter", "password": "geheim"}' \
    http://localhost:5000/users/login | jq
curl -s \
    -D "/dev/stderr" \
    -X POST \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer 22e6c5fc-8a5a-440e-b1f4-018deb9fd24e" \
    -d '{"pronouns": "Herr Dr. Dr."}' \
    http://localhost:5000/users/1/profile | jq
curl -s \
    -D "/dev/stderr" \
    -H "Authorization: Bearer 22e6c5fc-8a5a-440e-b1f4-018deb9fd24e" \
    http://localhost:5000/users/1/profile

Docker

Image bauen

docker build --tag ki_backed .

Container starten

Im Beispiel wird die SQLite Datenbank ./data/ki_backend.sqlite verwendet.

DB-Datei anlegen

touch data/ki_docker.sqlite
chmod a+rw data/ki_docker.sqlite

Container starten

docker run \
    --name=ki_backend \
    -v ${PWD}/data/ki_docker.sqlite:/app/data/ki_docker.sqlite \
    -e SQLALCHEMY_DATABASE_URI='sqlite:///data/ki_docker.sqlite' \
    -p 5000:5000 \
    ki_backend

Skills und Sprachen importieren

docker exec ki_backend sh -c "cd /app && /pyroot/bin/flask seed"

Produktionsumgebung

Für die Produktionsumgebung wird waitress benutzt.

run_prod.py führt die DB Migrationen aus und startet den Server.

Quellen