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:
parent
ee6ff8e9aa
commit
99f3171d0d
11
.editorconfig
Normal file
11
.editorconfig
Normal 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
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
venv/
|
venv/
|
||||||
|
*.pyc
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Cancymat Backend
|
# Candymat Backend
|
||||||
|
|
||||||
The backend providing the data and managing changing the data.
|
The backend providing the data and managing changing the data.
|
||||||
|
|
||||||
|
|
6
backend/data/fragen.json
Normal file
6
backend/data/fragen.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"text": "Dies ist eine Dummy Frage für Testzwecke"
|
||||||
|
}
|
||||||
|
]
|
14
backend/data/kandidaten.json
Normal file
14
backend/data/kandidaten.json
Normal 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"
|
||||||
|
}
|
||||||
|
]
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
python -m venv venv
|
python -m venv venv
|
||||||
|
|
||||||
source venv/bin/activate
|
source venv/bin/activate
|
||||||
|
|
5
backend/dev-start.sh
Executable file
5
backend/dev-start.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
source venv/bin/activate
|
||||||
|
|
||||||
|
env FLASK_APP=flask-server/main.py flask run
|
21
backend/flask-server/main.py
Normal file
21
backend/flask-server/main.py
Normal 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()
|
Loading…
Reference in a new issue