[Tutor] Help search files

Alan Gauld alan.gauld at btinternet.com
Thu Jul 5 11:27:41 CEST 2007


"Alejandro Decchi" <adecchi at gmail.com> wrote

> Yes I have a debian server runing apache. Can you give me a link?

I could give you lots of links but which is most useful will depend
on your level of knowledge. I get the impression that you are not
experienced in Web development and so may not even understand
concepts like CGI? If so the best place to start is by searching for
a Web tutorial on how to write CGI applications. There are many
of these and probably one in your native language, read that first.

Then look at the CGI tutorial onthe Python web site:

http://wiki.python.org/moin/CgiScripts

as well as the documentation on the cgi module:

http://docs.python.org/lib/module-cgi.html

> do not how to make the search and list the files found to download

The list of files is just plain HTML. Here is some very
primitive code:

print "<ul>"
for name in ['foo.txt','bar.txt', 'baz.txt']:
   print "<li> %s </li>" % name
print "</ul>"

In your case you need to surround the name with an anchor link too.
None of this is Python specific it is just basic web programming in 
HTML.

HTH,

Alan G.

>
> On 7/4/07, Alan Gauld <alan.gauld at btinternet.com> wrote:
>>
>> "Alejandro Decchi" <adecchi at gmail.com> wrote
>>
>> > Ok  but i have this form:
>> > <body>
>> > <form id="form1" name="form1" method="post"
>> > action="/cgi-bin/search.py">
>>
>> OK, You didn't make it clear that you meant a CGI program,
>> I was assuming you meant a GUI program. That adds a whole
>> heap of extra complexity. A lot depends on what web
>> mechanism/framework you are using. If we assume the
>> standard cgi module then you need to get the submited
>> data out of the request with the field_storage dictionary.
>> Then you need to call your search function and finally
>> format the results as HTML. Either offer to downoad a
>> particular file and have a second request start the download
>> or just send the file back, but that could be an unexpected result.
>> I'd offer the file as a link and let the user click on it to fetch 
>> it
>> from the server.
>>
>> But web programming is a whole different ball game.
>> You should look up some simple examples first.
>>
>> Alan G.
>>
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>


--------------------------------------------------------------------------------


> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 




More information about the Tutor mailing list