Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,5 @@ on:
- install dependencies from file: `pip install -r requirements.txt`
- install single pandas dependency `pip install pandas`
- checkout git branch (if exists) or create a new one (if it does not exist): `git checkout foo 2>/dev/null || git checkout -b foo`, see https://stackoverflow.com/questions/26961371/switch-on-another-branch-create-if-not-exists-without-checking-if-already-exi

- https://stackoverflow.com/questions/37362971/how-to-allow-post-method-with-flask
11 changes: 10 additions & 1 deletion api.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,13 @@ def stuff():
'result': prediction.item(0)
}

return Response('Please provide all neccessary parameters to get a prediction: zylinder, ps, gewicht, beschleunigung, baujahr', mimetype='application/json')
return Response('Please provide all neccessary parameters to get a prediction: zylinder, ps, gewicht, beschleunigung, baujahr', mimetype='application/json')

@app.route('/predict_multiple', methods = ['POST'])
def predict_multiple():
content = request.get_json(silent=True)
print('request body:', content)

return {
'result': 'blabla'
}
11 changes: 11 additions & 0 deletions call_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import requests

url = 'http://127.0.0.1:5000/predict_multiple'
myobj = [
{"input_1": "133", "input_2": "blabla"},
{"input_1": "200", "input_2": "200 blabla"},
]

x = requests.post(url, json=myobj)

print(x.text)
Loading