Return html data + serve a file

vergos.nikolas at gmail.com vergos.nikolas at gmail.com
Tue Oct 9 14:29:34 EDT 2018


Hello, iam using Python + Flask.
Iam trying to print some html and also serve a file to the user. My code is:


	pdata = pdata + '''<img src="/static/img/arrow.gif" align="left">'''


	# Prepare selected file for download....
	filename = request.form.get('filename')
	filepath = '/home/user/wsgi/static/files/'

	yield send_from_directory( filepath, filename, as_attachment=True )
	return pdata


The error i'm receiving is:

TypeError: 'generator' object is not callable
The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a generator.

Can you help me understand why iam getting this error and how i should write it?



More information about the Python-list mailing list