On Wednesday, May 29, 2019 at 10:15:49 AM UTC-7, Quang Lam wrote: > > Hi Dave > > Could you please show me more detail in code since i need to download the > CSV file store in the table? >
Look at appadmin.py around line 5824. The file is in yourapp/controllers. Basically: get query set headers # it does 'Content-disposition' as well as 'Content-Type' return str(db(query, filters).select()) You may not want the 'Content-disposition' header -- it's setting attachment and filename. If you're doing an existing csv file, rather than query results, then you need to read the file and either stringify it or stream it. But CSV is an ugly thing to show to a user; if the user needs query results in a table, then either SQLTABLE or SQLFORM.grid could be used, and I think the latter could also be used for a file you read. /dps > On Tuesday, May 28, 2019 at 11:00:42 PM UTC-7, Quang Lam wrote: >> >> Hi, i have a problem to display the CSV file stored in the table. >> >> the code below is in controller >> >> def view_performance(): >> files = db.Pass_Configuration(request.args(0, cast=int)) or >> redirect(URL('index')) // get the ID of Pass_Configuration table form the >> URL >> return dict(files=files) >> >> def download(): >> return response.download(request, db) //download function >> >> >> the code in the View as follows >> >> {{extend 'layout.html'}} >> <h1>{{='Performance'}}</h1><br> >> src="{{=URL('download', args=files.PerformanceFile)}}" >> >> i know i get the path to the file right but somehow it does not display >> the CSV file. it just displays the file path and nothing else. i know i am >> missing something but could not figure out >> could you please help me to point out what the mistake i have and how to >> fix it. thanks >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/5fd2c8c6-1ae5-45db-85cf-edb7db0c4ad8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.