Simple python cgi question

Discussion in 'Python' started by Stephen Boulet, Sep 17, 2003.

  1. 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
    Stephen Boulet, Sep 17, 2003
    #1
    1. Advertising

  2. Stephen Boulet

    Wilk Guest

    Stephen Boulet <> 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
    Wilk, Sep 17, 2003
    #2
    1. Advertising

  3. Wilk wrote:
    > Stephen Boulet <> 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 ...
    Stephen Boulet, Sep 17, 2003
    #3
  4. Stephen Boulet

    Wilk Guest

    Stephen Boulet <> writes:

    > Wilk wrote:
    >> Stephen Boulet <> 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
    Wilk, Sep 17, 2003
    #4
  5. Stephen Boulet

    Domenico Guest

    > 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
    Domenico, Sep 17, 2003
    #5
  6. 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 <> writes:
    >
    >
    >>Wilk wrote:
    >>
    >>>Stephen Boulet <> 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
    >
    Stephen Boulet, Sep 18, 2003
    #6
  7. Stephen Boulet <> wrote in message news:<>...
    > 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.
    Lothar Scholz, Sep 18, 2003
    #7
  8. Stephen Boulet

    Wilk Guest

    Stephen Boulet <> 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
    Wilk, Sep 18, 2003
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. LarsenMTL
    Replies:
    4
    Views:
    650
    Eric Walstad
    Nov 4, 2004
  2. praba kar

    Python-cgi or Perl-cgi script doubt

    praba kar, Jul 30, 2005, in forum: Python
    Replies:
    1
    Views:
    505
    Michael Sparks
    Jul 30, 2005
  3. Amir  Michail

    cgi relay for python cgi script

    Amir Michail, Oct 4, 2005, in forum: Python
    Replies:
    7
    Views:
    377
    Michael Ekstrand
    Oct 4, 2005
  4. epsilon
    Replies:
    4
    Views:
    303
    Gabriel Genellina
    Aug 22, 2007
  5. Ted Byers
    Replies:
    19
    Views:
    629
    Ilya Zakharevich
    Nov 30, 2009
Loading...

Share This Page