niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » python
advice needed for simple python web app
Post new topic   Reply to topic Page 1 of 2 [21 Posts] View previous topic :: View next topic
Goto page:  1, 2 Next
Author Message
M.E.Farmer
*nix forums Guru Wannabe


Joined: 20 Feb 2005
Posts: 105

PostPosted: Fri Feb 04, 2005 3:39 am    Post subject: Re: advice needed for simple python web app Reply with quote

I am no web expert but have recently used cherrypy to 'webify' a
script. It is very easy to get going and has its own server or can be
run behind Apache.
The only real problem I see is that the docs are still a little lite
for the new 2.0 series ,but they do have a newsgroup where the author
still answers questions.
Cherrypy2 is fairly logical and most of it is covered in the examples
on there website.
I can not speak for the other packages,have not used them yet Wink
hth,
M.E.Farmer
Back to top
Paul Rubin
*nix forums Guru


Joined: 28 Feb 2005
Posts: 1197

PostPosted: Fri Feb 04, 2005 3:43 am    Post subject: Re: advice needed for simple python web app Reply with quote

"Dan Perl" <danperl@rogers.com> writes:
Quote:
Basically, what I'm looking for is a web server that accepts an HTTP
request and invokes a python script. But I would like a "pythonic"
solution so a web server like Apache is a solution that I would like
to avoid. The server should also be as simple as possible to
administrate.

CGI and CGIHTTPServer (or whatever it's called) is conceptually the
> simplest. What does your app do?
Back to top
Dan Perl
*nix forums beginner


Joined: 19 Feb 2005
Posts: 32

PostPosted: Fri Feb 04, 2005 4:08 am    Post subject: Re: advice needed for simple python web app Reply with quote

"Paul Rubin" <http://phr.cx@NOSPAM.invalid> wrote in message
news:7xr7jxnddh.fsf@ruckus.brouhaha.com...
Quote:
"Dan Perl" <danperl@rogers.com> writes:
Basically, what I'm looking for is a web server that accepts an HTTP
request and invokes a python script. But I would like a "pythonic"
solution so a web server like Apache is a solution that I would like
to avoid. The server should also be as simple as possible to
administrate.

CGI and CGIHTTPServer (or whatever it's called) is conceptually the
simplest. What does your app do?

The application is just something I'm playing with to learn a little bit on
web apps. It uses an HTML form to send an email. The form takes inputs
like the From:, To: and Subject: fields and a text field.

I found the "Internet Protocols and Support" chapter in the Library
Reference that covers also the CGIHTTPServer. It's definitely something I
will have to read. Thanks.

Dan
Back to top
Dan Perl
*nix forums beginner


Joined: 19 Feb 2005
Posts: 32

PostPosted: Fri Feb 04, 2005 4:12 am    Post subject: Re: advice needed for simple python web app Reply with quote

"M.E.Farmer" <mefjr75@hotmail.com> wrote in message
news:1107491985.187092.268580@o13g2000cwo.googlegroups.com...
Quote:
I am no web expert but have recently used cherrypy to 'webify' a
script. It is very easy to get going and has its own server or can be
run behind Apache.
The only real problem I see is that the docs are still a little lite
for the new 2.0 series ,but they do have a newsgroup where the author
still answers questions.
Cherrypy2 is fairly logical and most of it is covered in the examples
on there website.
I can not speak for the other packages,have not used them yet Wink
hth,
M.E.Farmer

Thanks. I am no web expert either so I appreciate advice coming from
someone who was in a similar situation.

Twisted and CherryPy seemed to me to be the main choices based on what I
understand from their front pages with my limited knowledge on web apps.
Twisted feels more "developed" but also more complex at the same time. I
wanted opinions before I invest the time in studying either one of them.
Your opinion helps.

Dan
Back to top
Michele Simionato
*nix forums Guru Wannabe


Joined: 20 Feb 2005
Posts: 253

PostPosted: Fri Feb 04, 2005 4:44 am    Post subject: Re: advice needed for simple python web app Reply with quote

Dan Perl:
Quote:
The application is just something I'm playing with to learn a little
bit on
web apps. It uses an HTML form to send an email. The form takes
inputs
like the From:, To: and Subject: fields and a text field.

It is difficult to beat CGI + CGIHTTPServer for conceptual simplificity
and easy of use: however, Quixote comes close and it has a *much*
better support for forms. Here is an
example from the minidemo in the distribution, so you have an idea of
how the code looks
like:

Quote:
from quixote.publish import Publisher
from quixote.directory import Directory

class RootDirectory(Directory):

_q_exports = ['', 'hello']

def _q_index(self):
return '''<html
body>Welcome to the Quixote demo. Here is a
a href="hello">link</a>.
/body
/html
'''

def hello(self):
return '<html><body>Hello world!</body></html>'


Quote:
def create_publisher():
return Publisher(RootDirectory(),
display_exceptions='plain')


Quote:
if __name__ == '__main__':
from quixote.server.simple_server import run
print 'creating demo listening on http://localhost:8080/'
run(create_publisher, host='localhost', port=8080)

The exported methods of your directory class corresponds to Web pages;
_q_index
returns the main page, hello an hello word page. This works out of the
box with
no configuration at all, you don't need to create a cgi-bin directory,
nothing.
It is trivial to replace simple_server with a more serious server
(twisted_server,
scgi_server, etc. )

Notice: this example works in Quixote 2.0 which is currently in alpha.
Don't let
the "alpha" scares you: that means that the documentation is still a
bit rough and
few things are not fully settled down, but the framework is very much
usable.


Michele Simionato
Back to top
Paul Rubin
*nix forums Guru


Joined: 28 Feb 2005
Posts: 1197

PostPosted: Fri Feb 04, 2005 4:53 am    Post subject: Re: advice needed for simple python web app Reply with quote

"Dan Perl" <danperl@rogers.com> writes:
Quote:
The application is just something I'm playing with to learn a little bit on
web apps. It uses an HTML form to send an email. The form takes inputs
like the From:, To: and Subject: fields and a text field.

Be careful of exposing that script to the internet. Spammers will
exploit it.
Back to top
Dan Perl
*nix forums beginner


Joined: 19 Feb 2005
Posts: 32

PostPosted: Fri Feb 04, 2005 5:12 am    Post subject: Re: advice needed for simple python web app Reply with quote

"Paul Rubin" <http://phr.cx@NOSPAM.invalid> wrote in message
news:7xis58c1lw.fsf@ruckus.brouhaha.com...
Quote:
"Dan Perl" <danperl@rogers.com> writes:
The application is just something I'm playing with to learn a little bit
on
web apps. It uses an HTML form to send an email. The form takes inputs
like the From:, To: and Subject: fields and a text field.

Be careful of exposing that script to the internet. Spammers will
exploit it.

Do you mean publishing the script for other people to copy it or exposing
the web app so that other people may access it? Don't worry anyway, I won't
do either and I'm running 2 firewalls on my PC. It would be really naive to
expose the web app, wouldn't it?
Back to top
Brian Beck
*nix forums addict


Joined: 19 Feb 2005
Posts: 54

PostPosted: Fri Feb 04, 2005 5:18 am    Post subject: Re: advice needed for simple python web app Reply with quote

Dan Perl wrote:
Quote:
Basically, what I'm looking for is a web server that accepts an HTTP request
and invokes a python script. But I would like a "pythonic" solution so a
web server like Apache is a solution that I would like to avoid. The server
should also be as simple as possible to administrate.

As M.E.Farmer suggested, CherryPy is definitely what you are looking
for. I have done a bit of shopping around and this is pretty much as
straightforward as you can get.

From my experience, this appears to be the order from low-level to
high-level interfaces:

1. mod_python: As complex as you need it to be, since you can control
anything about the request & response process. But more up-front work
and decisions to make than CherryPy.
2. mod_python with Vampire: Directs you toward a specific publishing
framework that is similar to CherryPy.
3. CherryPy: Like Vampire but simpler and doesn't require mod_python.
The simplest blend between low-level server interface and
ease-of-publishing.
4. Twisted: Seems like this is a big package to work with, not sure how
easy it makes publishing once you get started-- better that someone else
comment on this.
5. Zope: The most complex solution, doesn't necessarily make the 'easy
things easy.' But covers all fronts in terms of what a user would ever need.
6. Zope with Plone: Adds a ton of publishing functionality. Has many
ways to extend, but none of them are fun. You'll have to learn such
complex APIs that Python will rarely help you.

Of course there are more, like Webware, but you didn't mention that and
I don't have experience with it.

--
Brian Beck
Adventurer of the First Order
Back to top
Dan Perl
*nix forums beginner


Joined: 19 Feb 2005
Posts: 32

PostPosted: Fri Feb 04, 2005 5:28 am    Post subject: Re: advice needed for simple python web app Reply with quote

"Michele Simionato" <michele.simionato@gmail.com> wrote in message
news:1107495895.697731.183550@z14g2000cwz.googlegroups.com...
Quote:
Dan Perl:
The application is just something I'm playing with to learn a little
bit on
web apps. It uses an HTML form to send an email. The form takes
inputs
like the From:, To: and Subject: fields and a text field.

It is difficult to beat CGI + CGIHTTPServer for conceptual simplificity
and easy of use: however, Quixote comes close and it has a *much*
better support for forms.

So Quixote is another framework I will have to look into. Best of all,
though, after adding Quixote to the list I decided I have enough words to do
a search. There were a few interesting finds, but one single link that
points to the best of them is:
http://www.python.org/moin/WebProgrammingShootOut
Back to top
Paul Rubin
*nix forums Guru


Joined: 28 Feb 2005
Posts: 1197

PostPosted: Fri Feb 04, 2005 5:31 am    Post subject: Re: advice needed for simple python web app Reply with quote

"Dan Perl" <danperl@rogers.com> writes:
Quote:
Be careful of exposing that script to the internet. Spammers will
exploit it.

Do you mean publishing the script for other people to copy it or exposing
the web app so that other people may access it?

I mean installing the script on a server where spammers can run it and
stick you with the blame for people getting unwanted mail. There used
to be some similar perl scripts running all over the place until that
happened.

Quote:
Don't worry anyway, I won't do either and I'm running 2 firewalls on
my PC. It would be really naive to expose the web app, wouldn't it?

Well, you should have some kind of user authentication if you expose
it, and you should read up a bit about security for web apps. Python
is actually not such a great language for this, but you certainly get
more readable code than you would with perl.
Back to top
Dan Perl
*nix forums beginner


Joined: 19 Feb 2005
Posts: 32

PostPosted: Fri Feb 04, 2005 6:00 am    Post subject: Re: advice needed for simple python web app Reply with quote

"Brian Beck" <exogen@gmail.com> wrote in message
news:ctv48p$75$1@eeyore.INS.cwru.edu...
Quote:
From my experience, this appears to be the order from low-level to
high-level interfaces:

1. mod_python: As complex as you need it to be, since you can control
anything about the request & response process. But more up-front work and
decisions to make than CherryPy.
2. mod_python with Vampire: Directs you toward a specific publishing
framework that is similar to CherryPy.
3. CherryPy: Like Vampire but simpler and doesn't require mod_python. The
simplest blend between low-level server interface and ease-of-publishing.
4. Twisted: Seems like this is a big package to work with, not sure how
easy it makes publishing once you get started-- better that someone else
comment on this.
5. Zope: The most complex solution, doesn't necessarily make the 'easy
things easy.' But covers all fronts in terms of what a user would ever
need.
6. Zope with Plone: Adds a ton of publishing functionality. Has many ways
to extend, but none of them are fun. You'll have to learn such complex
APIs that Python will rarely help you.

This is exactly the kind of summary that I think should be in a
WebProgrammingShootOut (see another one of my postings in this thread) but I
failed to find such a summary. Thanks, Brian! Anyone can add to the list?

BTW, there are other people who seem to have been also confused by the wide
spectrum of choices for this problem:
http://pyre.third-bit.com/hippoblog/archives/000058.html
Back to top
Paul Rubin
*nix forums Guru


Joined: 28 Feb 2005
Posts: 1197

PostPosted: Fri Feb 04, 2005 6:10 am    Post subject: Re: advice needed for simple python web app Reply with quote

"Dan Perl" <danperl@rogers.com> writes:
Quote:
This is exactly the kind of summary that I think should be in a
WebProgrammingShootOut (see another one of my postings in this
thread) but I failed to find such a summary. Thanks, Brian! Anyone
can add to the list?

If you're just trying to get a conceptual understanding of web
programming, I suggest you start with cgi.

Next you might want to read Philip and Alex's Guide to Web Publishing:

http://philip.greenspun.com/panda/

It's out of date and the examples use Tcl and Oracle instead of
Python, but it's still a good explanation of how database-driven web
sites work. The rest (like languages frameworks) is just a matter of
picking some implementation parameters.
Back to top
Dave Cook
*nix forums addict


Joined: 20 Feb 2005
Posts: 74

PostPosted: Fri Feb 04, 2005 7:46 am    Post subject: Re: advice needed for simple python web app Reply with quote

On 2005-02-04, Dan Perl <danperl@rogers.com> wrote:

Quote:
I have a pretty simple python script and I would like to turn it into a web
application but web apps are a domain I know very little about. I know that
Twisted, CherryPy, Plone and Zope exist but not exactly what they do. I

I think CherryPy is the lightest and easiest if you need a built-in server.
I was impressed by its intuitiveness, though I don't really like the default
templating system.

I'm using Nevow (slick!) and Twisted now, but you pay for the flexiblility
with a steep learning curve, and lack of documentation and API stability are
an issue with Nevow.

Inspired by an example on Bruce Eckel's blog, I tried writing a web app with
only the server that comes with the standard lib, but it was just too hard
for me to build an app starting from that low a level. The frameworks help a
lot here.

Dave Cook
Back to top
Fred Pacquier
*nix forums beginner


Joined: 11 Apr 2005
Posts: 12

PostPosted: Fri Feb 04, 2005 10:45 am    Post subject: Re: advice needed for simple python web app Reply with quote

"Dan Perl" <danperl@rogers.com> said :

Quote:
This is exactly the kind of summary that I think should be in a
WebProgrammingShootOut (see another one of my postings in this thread)
but I failed to find such a summary. Thanks, Brian! Anyone can add
to the list?

I myself am also into (very) simple web apps and hence simple, easy-to-
learn web frameworks.

CherryPy is a very nice kit, still simple enough but already (IMO)
somewhat on the powerful, batteries-included side for a beginner -- and,
as you noted, a bit under-documented at the moment.

There are a couple of others that will get you started without too much
effort (in part because simplicity is one of their design points) and
without limiting you too much either : Karrigell by Pierre Quentel and
Snakelets by Irmen de Jong.

They're somewhat similar in scope and concept : it will be mostly a
matter of which one 'fits your brain' best. Myself I settled on
Snakelets, not least because it has some of the better docs out there.

Quote:
BTW, there are other people who seem to have been also confused by the
wide spectrum of choices for this problem:

That's an old debate in the Python world, yes. The "one true way to do
it" motto of the language itself doesn't apply to its web frameworks :)

See the recent "Ruby on Rails" threads for a discussion of whether this
is good or bad...

--
YAFAP : http://www.multimania.com/fredp/
Back to top
Dan Perl
*nix forums beginner


Joined: 19 Feb 2005
Posts: 32

PostPosted: Fri Feb 04, 2005 1:20 pm    Post subject: Re: advice needed for simple python web app Reply with quote

"Paul Rubin" <http://phr.cx@NOSPAM.invalid> wrote in message
news:7xis58reac.fsf@ruckus.brouhaha.com...
Quote:
If you're just trying to get a conceptual understanding of web
programming, I suggest you start with cgi.

Next you might want to read Philip and Alex's Guide to Web Publishing:

http://philip.greenspun.com/panda/

It's out of date and the examples use Tcl and Oracle instead of
Python, but it's still a good explanation of how database-driven web
sites work. The rest (like languages frameworks) is just a matter of
picking some implementation parameters.

This matches pretty much what I've decided to do. I'll start with cgi and
CGIHTTPServer because I'll learn more from that and then move to a
framework, quite likely CherryPy, although by that time I may change my
choice. Philip Greenspun's book looks good and I'll have to go through it.
Thanks for the advice.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 2 [21 Posts] Goto page:  1, 2 Next
View previous topic :: View next topic
The time now is Fri Jan 09, 2009 12:44 am | All times are GMT
navigation Forum index » Programming » python
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Python proficiency test Kent Johnson python 0 Fri Jul 21, 2006 10:47 am
No new posts Since there was talk of if-then-else not being allowed in... Casey Hawthorne python 5 Fri Jul 21, 2006 3:41 am
No new posts ECPG (usage of simple select statement) Jasbinder Bali PostgreSQL 0 Fri Jul 21, 2006 3:28 am
No new posts A simple bash script JPB Suse 2 Fri Jul 21, 2006 2:19 am
No new posts Simple ?? NIS problem Gary Solaris 4 Thu Jul 20, 2006 10:27 pm

Guitar Lesson | Facebook Proxy | Secured Loans | eBay | Secured Loans
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2700s ][ Queries: 16 (0.1360s) ][ GZIP on - Debug on ]