Skip to content
Snippets Groups Projects
Commit cddfd47a authored by Yannic Nevado Hidalgo's avatar Yannic Nevado Hidalgo
Browse files

add(setup): initiale Einrichtung der API inklusive Datenbank

parent 3291b463
No related branches found
No related tags found
No related merge requests found
FROM python:3.9.6
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
COPY ./app .
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
\ No newline at end of file
FROM postgres:13.6
RUN localedef -i de_DE -c -f UTF-8 -A /usr/share/locale/locale.alias de_DE.UTF-8
ENV LANG de_DE.utf8
COPY initial_setup.sql /docker-entrypoint-initdb.d/
\ No newline at end of file
CREATE DATABASE "web-sec";
\c web-sec;
CREATE TABLE "benutzer" (
customerID SERIAL NOT NULL,
vorname text NOT NULL,
nachname text NOT NULL,
email varchar(255) NOT NULL,
PRIMARY KEY(customerID)
);
INSERT INTO
"benutzer" (vorname, nachname, email)
VALUES
('Alice','Apple', 'alice@apple.net'),
('Bob','Banana', 'bob@banana.net'),
('Mallory','Mango', 'mallory@mango.net');
\ No newline at end of file
.DS_Store
.env
.flaskenv
*.pyc
*.pyo
env/
venv/
.venv/
env*
dist/
build/
*.egg
*.egg-info/
_mailinglist
.tox/
.cache/
.pytest_cache/
.idea/
docs/_build/
.vscode
# Coverage reports
htmlcov/
.coverage
.coverage.*
*,cover
\ No newline at end of file
File added
= Task1 Security Of Web Applications
Aufgabe 1 des Security of Web Applications Ferienkurses.
== Lokales setup
* Docker und docker-compose installieren
== Anwendung starten
[source,bash]
----
# Docker Images bauen
docker-compose build
# Starten der Datenbank und API
docker-compose up
----
* Nach dem Initialen Starten der Datenbank werden folgende Benutzer angelegt:
[cols="4", options="header"]
|===
| customerID
| Vorname
| Vorname
| E-Mail
| 1
| Alice
| Apple
| alice@apple.net
| 2
| Bob
| Banana
| bob@banana.net
| 3
| Mallory
| Mango
| mallory@mango.net
|===
== Routen
Die Routen sind Passwort geschützt.
[source,bash]
----
# benutzername: admin
# passwort: admin
----
=== GET
* `http://localhost:5000/api/user/:customerID`
** Gibt die E-Mail Adresse eines Benutzers zurück
=== POST
* `http://localhost:5000/api/user`
** Erstellt einen Benutzer mit dem übergebenen Body
[source,bash]
----
{
"vorname":"max",
"nachname":"mustermann",
"email":"max@mustermann.net"
}
----
=== DELETE
* `http://localhost:5000/api/user/:customerID`
** Löscht einen Benutzer anhand seiner `customerID`
\ No newline at end of file
# Task1 Security Of Web Applications
Aufgabe 1 des Security of Web Applications Ferienkurses.
\ No newline at end of file
import json
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return json.dumps({'name': 'alice',
'email': 'alice@outlook.com'})
if __name__ == "__main__":
app.run()
\ No newline at end of file
# Use postgres/example user/password credentials
version: '3.9'
services:
database:
container_name: postgres
build:
context: .docker/database
restart: always
environment:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
adminer:
image: adminer
restart: always
depends_on:
- database
ports:
- 8080:8080
app:
container_name: flask-api
build:
context: .
dockerfile: .docker/api/Dockerfile
restart: always
depends_on:
- database
ports:
- 5000:5000
\ No newline at end of file
Flask==2.0.3
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment