473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

"save as" python script

1
I have a script "licence.cgi" write in python which generate text files and I would like that the user click on a button and he can download this file.

_1er solution:_
I found in my research that I have to add the Content-Disposition... So I created an other script call /download.cgi /and I obtain a popup "save as" but how the script "licence.cgi" can give the variable filename to the script download.cgi?

-----------------------------------------------------------*_
licence.cgi
_*print "Content-type: text/html"
print
...
filename="/var/www/licence/licence-20070511-152214"
...
print '<form name="input" action=%s method="POST"><INPUT TYPE="SUBMIT" VALUE="VIEW the file"></form>' %filename
print '<form method="POST" action="/cgi-bin/downloadfile.cgi"> <INPUT TYPE="SUBMIT" VALUE="DOWNLOAD the file"></form>'
...

-----------------------------------------------------------
download.cgi
#!/usr/bin/python

import string, sys
import cgi
import cgitb; cgitb.enable()

print "Content-Disposition: attachment; filename= %s " %filename
print "Content-Type: application/text"
print

try:
fp=open(licencefile, "r")
content = fp.read()
print content
except:
print "Couldn't find the file."
-----------------------------------------------------------
_
2 solution:_
I would like to have only one script, only "licence.cgi". How can I do ?


Thanks you very much for your help
--

Laetitia
May 14 '07 #1
0 1599

Sign in to post your reply or Sign up for a free account.

Similar topics

27
by: Curious Angel | last post by:
I have a resume in PDF format and I want anyone who LEFT-OR-RIGHT clicks the link to force the file to be saved, and in any event _not_ opened. Since the PDF will be in his cache in any event, I...
3
by: AJ | last post by:
Hi , I am trying to dynamically change file name of an html that is generated through a cgi script, I know that for it is easy to do this for other type of files such as pdf or csv which we...
4
by: Richard | last post by:
Hi I'm new to ASP/Web programming so any help would be appreciated... Situation: On my web page I would like to present a link {or button} that would allow the user to download a large file. ...
5
by: Paul Sullivan | last post by:
We are a state agency that views protected medical information via our intranet. The screens even have privacy shields. Alarmingly, uses can "Print" and "Save As" which destroys the protection of...
60
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type?...
2
by: hypermonkey2 | last post by:
Hi there! I am using the "shelve" module in a script to save information in between runtime sessions of the program. (its a sort of data collector, so its important to hold on to anything computed...
0
by: Edwin.Madari | last post by:
since choice of dbm used by shelve http://docs.python.org/lib/node327.html depends on os, and whats available on it, shevle files saved on one os, most likely do not work on another os, sometimes on...
2
by: chardish | last post by:
Hello, I'm trying to find out in a script where the location of the current python is. (I'm writing an installer script in python for a simple server application, so i'm going to do a...
2
by: ejrfigueiredo | last post by:
Hi, Is there a way to get a script function to save a page without the execCommand (which works on IE but doesn't on Firefox). Below there's the code I'm using, I took it from a template page...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.