Go to file
weeman a9f9c36eda
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
add cors
2021-06-21 22:21:25 +02:00
data add Dockerfile 2021-06-14 21:56:20 +02:00
ki add cors 2021-06-21 22:21:25 +02:00
migrations extract profile 2021-06-20 19:25:27 +02:00
.drone.yml only build prs and main 2021-06-21 22:00:33 +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 Ignore *.pyc-files for git 2021-06-21 16:12:54 +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 cors 2021-06-21 22:21:25 +02:00
Pipfile.lock add cors 2021-06-21 22:21:25 +02:00
README.md Merge pull request 'Logging' (#7) from feature-logging into main 2021-06-21 21:44:33 +02:00
app.py add cors 2021-06-21 22:21:25 +02:00
env.dev add cors 2021-06-21 22:21:25 +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
flask db upgrade
flask seed
flask run

http://localhost:5000/

Tests ausführen

python -m unittest discover ki

Linting

flake8

Formatierung

Um ein einheitliches Quellcode-Erlebnis zu haben, kann der Code mit yapf neu formatiert werden:

yapf -i --recursive ki/

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