473,396 Members | 1,891 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,396 software developers and data experts.

Simple python cgi question

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
7 2379
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
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
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
> 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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chuck Amadi | last post by:
Has anyone got a simple python script that will parse a linux mbox and create a large file to view . Cheers Chu
4
by: Jonathan Fine | last post by:
Hi I'm looking for a simple Python + Tk text editor. I want it as a building block/starting point. I need basic functions only: open a file, save a file, new file etc. It has to be open...
2
by: Trimbitas Sorin | last post by:
Hello I have a simple syntax question : What does the following line mean: 1: %checkType; ?? I know that @test="" is an array and $test="" is a simple variable. Thank you With best regards...
13
by: Jason Swett | last post by:
I want to do graphics with C++. Surprisingly, so far nobody has been able to tell me anything helpful. How do I do it? Any input would be greatly appreciated. Jason
51
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct...
2
by: Harry | last post by:
Hi All, It is nice to join the python group. Can someone please help me with a python question? I have the following object which is like a list of tuples What command do I use to get the value...
0
by: Vishal Patil | last post by:
Check out a new and simple Python base genetic algorithm framework at http://vishpat.googlepages.com/pgap -- Motivation will almost always beat mere talent.
1
by: Scheol Service | last post by:
---------- Forwarded message ---------- From: Scheol Service <scheols@gmail.com> Date: Nov 29, 2006 10:57 PM Subject: Python Question About Compiling. To: mailto:python-list@python.org Im...
3
by: Chrism2671 | last post by:
I'm new to XSLT/XML and I have a very simple, quick question. i've been trying to convert simple xml files into CSV files and have made a simple XSLT template using the w3 tutorials, but it doesn't...
1
by: Tim Roberts | last post by:
Ethan Furman <ethan@stoneleaf.uswrote: More than that, the brackets are CAUSING this problem. The "%" formatting operator expects to find either a single item, or a tuple containing multiple...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.