Aloha, i am trying to follow this tutorial and here is a Git of it
I was pretty successfull with it but now i am trying to modify this code a little bit :)
from flask import Flask, jsonify, request, render_template
app = Flask(__name__)
Persons = [{'name' : 'Arnold' , 'email' : 'disceps@gmail.com'},
{'name' : 'Alex Mikro' , 'email' : 'kovalsky@gmail.com'},
{'name' : 'Phost Arnold' , 'email' : 'arn@gmx.de'}]
So, i've created the following value
For now, i would like to get a POST responce from this...So, if a name is equall to the typed name, there should be a responce..
@app.route('/pers', methods=['POST'])
def addOne():
email = request.form['email']
name = request.form['name']
if name and email:
pers = [persons for persons in Persons if persons['name'] == name]
pers[0]['name'] = request.get_json(force=True).get('name')
if name == pers[0]:
return jsonify({'name' : name})
return jsonify({'error' : 'Missing data!'})
but unfortunately,this doesn't work..
p.s. the code mentioned in the video
def addOne():
email = request.form['email']
name = request.form['name']
if name and email:
newName = name[::-1]
return jsonify({'name' : newName})
return jsonify({'error' : 'Missing data!'})
is working without any troubles :) So i think, there is a problem in my IF-Statement...