@app.route('/register', methods=['POST'])
def add_data():
    data = request.get_json()
    user = Usuario.query.filter_by(e_mail=data['e_mail']).first()
    nick = Usuario.query.filter_by(nick=data['nick']).first()
    if user:
        return jsonify({'error': 'Existe correo'})
    if nick:
        return jsonify({'error': 'Existe nick'})
    register = Usuario(nick=data['nick'], password=generate_password_hash(data['password']), e_mail=data['e_mail'], foto_de_perfil='platon.jpg')
    db.session.add(register)
    db.session.commit()
    token = jwt.encode({'nick': data['nick'], 'exp': (datetime.datetime.utcnow() + datetime.timedelta(minutes=30))}, app.config['SECRET_KEY'])
    return jsonify({'token': token.decode('UTF-8')})
@app.route('/register', methods=['POST'])
def add_data():
    data = request.get_json()
    user = Usuario.query.filter_by(e_mail=data['e_mail']).first()
    nick = Usuario.query.filter_by(nick=data['nick']).first()
    if user:
        return jsonify({'error': 'Existe correo'})
    if nick:
        return jsonify({'error': 'Existe nick'})
    register = Usuario(nick=data['nick'], password=generate_password_hash(data['password']), e_mail=data['e_mail'], foto_de_perfil='platon.jpg')
    db.session.add(register)
    db.session.commit()
    token = jwt.encode({'nick': data['nick'], 'exp': (datetime.datetime.utcnow() + datetime.timedelta(minutes=30))}, app.config['SECRET_KEY'])
    return jsonify({'token': token.decode('UTF-8')})