コード例 #1
0
def registro():
    if request.method == 'GET':
        try:
            return render_template('registro.html')
        except:
            return jsonify({'trace': traceback.format_exc()})

    if request.method == 'POST':
        try:
            # Alumno: Implemente
            # Obtener del HTTP POST JSON el nombre y los pulsos
            # name = ...
            # age = ...
            # nationality = ...
            # persona.insert(name, int(age), nationality)

            name = str(request.form.get('name'))
            age = str(request.form.get('age'))
            nationality = str(request.form.get('nationality'))

            if (name is None or age is None or age.isdigit() is False
                    or nationality is None):
                return Response(status=400)

            persona.insert(name, int(age), nationality)

            return Response(status=200)
        except:
            return jsonify({'trace': traceback.format_exc()})
コード例 #2
0
ファイル: app.py プロジェクト: PythoNove/api_service_python
def registro():
    if request.method == 'POST':
        # Obtener del HTTP POST JSON el nombre y los pulsos
        name = str(request.form.get('name'))
        age = int(request.form.get('age'))
        nationality = str(request.form.get('nationality'))

        persona.insert(name, int(age), nationality)
        return Response(status=200)
コード例 #3
0
def registro():
    if request.method == 'POST':
        # Obtener del HTTP POST JSON el nombre y los pulsos
        name = str(request.form.get('name'))
        age = str(request.form.get('age'))
        nationality = str(request.form.get('nationality'))
        
        if (name is None or age is None or age.isdigit() is False or nationality is None):
            return Response (status=400)
        
        persona.insert(name, int(age), nationality)
        return Response(status=200)
コード例 #4
0
def registro():
    if request.method == 'GET':
        try:
            return render_template('registro.html')
        except:
            return jsonify({'trace': traceback.format_exc()})

    if request.method == 'POST':
        try:
          
            name = str(request.form.get('name'))
            age = str(request.form.get('age'))
            nationality = str(request.form.get('nationality'))
            persona.insert(name, int(age), nationality)
            return Response(status=200)
        except:
            return jsonify({'trace': traceback.format_exc()})
コード例 #5
0
def registro():
    if request.method == 'GET':
        try:
            return render_template('registro.html')
        except:
            return jsonify({'trace': traceback.format_exc()})

    if request.method == 'POST':
        try:
            # Alumno: Implemente
            # Obtener del HTTP POST JSON el nombre y los pulsos

            name = str(request.json['name'])
            age = str(request.json['age'])
            nationality = str(request.json['nationality'])
            persona.insert(name, int(age), nationality)
            return Response(status=200)
        except:
            return jsonify({'trace': traceback.format_exc()})