This works:
from flask import Flask, request_started
app = Flask(__name__)
app.debug = True
def echo(sender, **extra):
return print('request_started')
request_started.connect(echo)
@app.route('/')
def index():
return 'index page'
while this doesn't:
from flask import Flask, request_started
app = Flask(__name__)
app.debug = True
request_started.connect(lambda sender, **extra: print('request_started'))
@app.route('/')
def index():
return 'index page'
Why is that?
the first outputs correctly while the lambda gives nothing i.e. no errors.
I'm using python 3.6
Apparently, it has nothing to do with the print function, I also tried this and it didn't work out.
request_started.connect(lambda sender, **extra: open('output', 'w').write('request_started\n'))
~ UPDATE ~
Now, this works and I'm confused !
echo = lambda sender, **extra: print('request_started')
request_started.connect(echo)