By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,584 Members | 1,803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,584 IT Pros & Developers. It's quick & easy.

Simple python cgi question

P: n/a
First of all, I'm not sure that the easiest way to do this is with
python ...

I'd like to set up a web page that would accept a text file, process it
with a local program, and then make available generated pdf and
postscript files for downloading.

I'd like to limit the size of the file to be uploaded.

I have apache2 already up. Is this a job for (mod_)python?

-- Stephen

Jul 18 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Stephen Boulet <st*****@SPAM.theboulets.IS.BAD.net> writes:
First of all, I'm not sure that the easiest way to do this is with
python ...

I'd like to set up a web page that would accept a text file, process
it with a local program, and then make available generated pdf and
postscript files for downloading.

I'd like to limit the size of the file to be uploaded.

I have apache2 already up. Is this a job for (mod_)python?


Yes why not ?

--
William Dode - http://flibuste.net
Jul 18 '05 #2

P: n/a
Wilk wrote:
Stephen Boulet <st*****@SPAM.theboulets.IS.BAD.net> writes:

First of all, I'm not sure that the easiest way to do this is with
python ...

I'd like to set up a web page that would accept a text file, process
it with a local program, and then make available generated pdf and
postscript files for downloading.

I'd like to limit the size of the file to be uploaded.

I have apache2 already up. Is this a job for (mod_)python?

Yes why not ?


I was hoping for a bit more detail ...

Jul 18 '05 #3

P: n/a
Stephen Boulet <st*****@SPAM.theboulets.IS.BAD.net> writes:
Wilk wrote:
Stephen Boulet <st*****@SPAM.theboulets.IS.BAD.net> writes:
First of all, I'm not sure that the easiest way to do this is with
python ...

I'd like to set up a web page that would accept a text file, process
it with a local program, and then make available generated pdf and
postscript files for downloading.

I'd like to limit the size of the file to be uploaded.

I have apache2 already up. Is this a job for (mod_)python?

Yes why not ?


I was hoping for a bit more detail ...


If you will do it in cgi, look at the cgi module, and for the pdf look
at http://www.reportlab.com

After, try to be more precise in your question if you want more
details...

bye

--
William Dode - http://flibuste.net
Jul 18 '05 #4

P: n/a
> First of all, I'm not sure that the easiest way to do this is with
python ...
python works great as a glue language. and you can *definitely* write
that script in python.
I'd like to set up a web page that would accept a text file, process it
with a local program, and then make available generated pdf and
postscript files for downloading.
no problem at all -- use os.system() or open a pipe via popen. then
serve a page with links to the generated files. finally (if you're a
1337 sysadmin) set up a cron job which every hour deletes .pdf and .ps
files older than (let's say) 5 minutes.
I'd like to limit the size of the file to be uploaded.


read the file into a buffer and stop reading after reaching the size
you decide. (disclaimer: I've never done this myself ;)

domenico
Jul 18 '05 #5

P: n/a
I don't want report lab since I'll be using lilypond to generate the
pdfs (I mentioned that I'd be calling the pdf generating program from
python).

What I needed to know was how to upload a file, really. I thought it
might be trivial, but maybe not so ...

I'll have to give the mod_python docs some study.

-- Stephen

Wilk wrote:
Stephen Boulet <st*****@SPAM.theboulets.IS.BAD.net> writes:

Wilk wrote:
Stephen Boulet <st*****@SPAM.theboulets.IS.BAD.net> writes:
First of all, I'm not sure that the easiest way to do this is with
python ...

I'd like to set up a web page that would accept a text file, process
it with a local program, and then make available generated pdf and
postscript files for downloading.

I'd like to limit the size of the file to be uploaded.

I have apache2 already up. Is this a job for (mod_)python?

Yes why not ?


I was hoping for a bit more detail ...

If you will do it in cgi, look at the cgi module, and for the pdf look
at http://www.reportlab.com

After, try to be more precise in your question if you want more
details...

bye


Jul 18 '05 #6

P: n/a
Stephen Boulet <st*****@SPAM.theboulets.IS.BAD.net> wrote in message news:<MH********************@speakeasy.net>...
First of all, I'm not sure that the easiest way to do this is with
python ...

I'd like to set up a web page that would accept a text file, process it
with a local program, and then make available generated pdf and
postscript files for downloading.

I'd like to limit the size of the file to be uploaded.

I have apache2 already up. Is this a job for (mod_)python?

-- Stephen


File upload size restriction is a job for apache. If you try to do
this in a CGI handler its to late to protect against "Denial Of
Service" attacks.

With modpython you can check the content-length header and abort
before you process the data.
Jul 18 '05 #7

P: n/a
Stephen Boulet <st*****@SPAM.theboulets.IS.BAD.net> writes:
I don't want report lab since I'll be using lilypond to generate the
pdfs (I mentioned that I'd be calling the pdf generating program from
python).

What I needed to know was how to upload a file, really. I thought it
might be trivial, but maybe not so ...


Yes it's trivial, you'll retreive the file with cgi.FieldStorage(),
you'll pass it to your local app with popen (a pipe) and retreive the
pdf with the pipe or open (a file), control the size of the buffer and
send the result with print.

Before, you'll print the right header content-type: application/pdf

bye

--
William Dode - http://flibuste.net
Jul 18 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.