Added simple flask API server

* Can respond to very basic requests with dummy data
* added editorconfig
* added scripts for starting the flask-server in dev mode
This commit is contained in:
Christoph Lienhard 2019-08-31 14:46:07 +02:00
parent ee6ff8e9aa
commit 99f3171d0d
8 changed files with 61 additions and 1 deletions

11
.editorconfig Normal file
View file

@ -0,0 +1,11 @@
root = true
[*]
charset = utf-8
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.py]
indent_size = 4

1
.gitignore vendored
View file

@ -1 +1,2 @@
venv/
*.pyc

View file

@ -1,4 +1,4 @@
# Cancymat Backend
# Candymat Backend
The backend providing the data and managing changing the data.

6
backend/data/fragen.json Normal file
View file

@ -0,0 +1,6 @@
[
{
"id": 0,
"text": "Dies ist eine Dummy Frage für Testzwecke"
}
]

View file

@ -0,0 +1,14 @@
[
{
"id": 0,
"vorname": "Max",
"name": "Mustermann",
"email": "max.mustermann@yahoo.com"
},
{
"id": 1,
"vorname": "Erika",
"name": "Mustermann",
"email": "erika.mustermann@yahoo.com"
}
]

View file

@ -1,3 +1,5 @@
#!/usr/bin/env bash
python -m venv venv
source venv/bin/activate

5
backend/dev-start.sh Executable file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
source venv/bin/activate
env FLASK_APP=flask-server/main.py flask run

View file

@ -0,0 +1,21 @@
from flask import Flask, escape, request
import json
import os
app = Flask(__name__)
@app.route('/')
def root():
return "Candymat Data Backend"
@app.route('/fragen')
def fragen():
with open('data/fragen.json', 'r') as json_file:
return json_file.read()
@app.route('/kandidaten')
def kandidaten():
with open('data/kandidaten.json', 'r') as json_file:
return json_file.read()