Created
September 6, 2017 11:38
-
-
Save kn0wm4d/8a03cc0cf751500b253adc2f47aeb362 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FUNCIONAMIENTO BÁSICO FLASK + CELERY | |
@app.route('/example', methods=['GET', 'POST']) esto iniciará la funcion example | |
@login_required # Limita acceso a usuarios logueados | |
def example(): | |
if request.method == 'POST': | |
# validaciones del form en request.form['param'] | |
param1 = request.form['param1'] | |
# objeto current_user contiene los atributos de la clase User() (en models.py) | |
try: | |
funcionsegundoplano.apply_async(args=[param1, param2...]) | |
msg = 'Trabajo iniciado!' | |
flash(msg, 'alert-success') | |
return render_template('pages/dashboard.html') | |
except: | |
error = 'Ooops, something went wrong.' | |
flash(error, 'alert-danger') | |
return render_template('pages/dashboard.html') | |
return redirect('/user') # redirecciona para peticiones que no son POST | |
@celery.task | |
def funcionsegundoplano(param1, param2): | |
with app.app_context(): | |
system("sqlmap -u " + params) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment