使用python intranet下载csv文件

使用python intranet下载csv文件,python,csv,web,download,intranet,Python,Csv,Web,Download,Intranet,大家好,这是我制作的python web应用程序 """ This is where we start the actual web application """ number_of_leads= counter unmatched_leads= len(getLeadSettings(in_leads)[0]) #lead_details=[number_of_leads,unmatched_leads] pop_before=in

大家好,这是我制作的python web应用程序

    """
    This is where  we start the actual web application
    """
    number_of_leads= counter
    unmatched_leads= len(getLeadSettings(in_leads)[0])
    #lead_details=[number_of_leads,unmatched_leads]

    pop_before=int(getPop(coveredzips))
    for z in ziplist:
        if z not in coveredzips:
            coveredzips+=[z]

    pop_after=int(getPop(coveredzips))
    ziplist_pop_percentage=float((ziplist_pop*100.0)/pop_before)
    popdata = [ziplist_pop, pop_before, pop_after,ziplist_pop_percentage]

    number_can_generate= str(float((number_of_leads)/(ziplist_pop/1000000.0))) + " leads per Million"

    lead_details=[number_of_leads,unmatched_leads,number_can_generate]

    file=csv_file
    return render.region_report(partners = partners, popdata = popdata ,lead_details=lead_details,file=file)
    return render.index(greeting = greeting)



    #l=getRegionsWithPop(current_regions)
    #u=getRegionWithPop(l)
    #return u
if __name__ == "__main__":
    app.run()
我正在将整个结果转发到region_report.html

而region_report.html如下所示

$def with (partners, popdata , lead_details,file)

<html>

    <head>
        <title>Agents with overlapping territories</title>
    </head>
    <h2 align="center" style="color:green">Partner details with overlapping territories</h2>
$if partners:
    <table border="1" style="width:100%" bgcolor="#FFFFCC"  border="black" >
    <tr><td><b>PID</b></td><td><b>Name</b></td><td><b>Lead limit</b></td><td><b>Profit</b></td><td><b>Region percentage</b></td><td><b>Number of leads</b></td></tr>
    $for pid,data in partners.items():
        <tr><td>$pid</td><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td><td>$data[4]</td></tr>
    </table>
$else:
    Oops!
<br/>   
$if popdata:
    <table border="1" style="width:38.5%" bgcolor="#FFFFCC" >
    <tr><td><b>Zip list population<b></td><td>$popdata[0]</td></tr>
    <tr><td><b>Total covered population without ziplist<b></td><td> $popdata[1]</td></tr>
    <tr><td><b>Total covered population with ziplist</td><td> $popdata[2]</td></tr>
    <tr><td><b>Percentage of the population covered </td><td> $popdata[3]</td></tr>
$if lead_details:
    <tr><td><b>Number of leads in the ziplist from the last month </td><td> $lead_details[0]</td></tr>
    <tr><td><b>Number of leads which are unmatched in the last month </td><td> $lead_details[1]</td></tr>
    <tr><td><b>Number of leads we can generate on average </td><td> $lead_details[2]</td></tr>
    </table>
    <button type="submit" value="Submit">Download</button>
$else:
    Oops!

</body>
</html>
$def with(合作伙伴、popdata、潜在客户详细信息、文件)
具有重叠区域的代理
具有重叠区域的合作伙伴详细信息
$if合作伙伴:
PIDNameLead LimitProfit区域百分比潜在客户数量
$pid,partners.items()中的数据:
$pid$data[0]$data[1]$data[2]$data[3]$data[4]
$else:
哎呀!

$if数据: Zip列表人口$popdata[0] 不含ziplist$popdata的总覆盖人口[1] ziplist$popdata的总覆盖人口[2] 人口覆盖率$popdata[3] $if潜在客户详细信息: 上个月ziplist中的lead数量$lead_details[0] 上月未匹配的潜在客户数量$lead_详细信息[1] 我们平均可以生成$lead_details的潜在客户数量[2] 下载 $else: 哎呀!
在region_report中,我添加了一个下载按钮。我希望该按钮能够正常工作,以便将整个数据作为csv下载。谁能告诉我怎么做


谢谢

首先创建
csv
文件并将其保存在磁盘上

然后添加链接
,而不是

您可以使用
CSS
使此链接看起来像一个按钮