Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #55108 > unrolled thread

Do I really need a web framework?

Started bydufriz@gmail.com
First post2013-09-30 12:57 -0700
Last post2013-09-30 21:00 -0400
Articles 5 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  Do I really need a web framework? dufriz@gmail.com - 2013-09-30 12:57 -0700
    Re: Do I really need a web framework? Tim Delaney <timothy.c.delaney@gmail.com> - 2013-10-01 06:39 +1000
    Re: Do I really need a web framework? John Gordon <gordon@panix.com> - 2013-09-30 21:53 +0000
    Re: Do I really need a web framework? waynejwerner@gmail.com - 2013-09-30 15:16 -0700
    Re: Do I really need a web framework? Roy Smith <roy@panix.com> - 2013-09-30 21:00 -0400

#55108 — Do I really need a web framework?

Fromdufriz@gmail.com
Date2013-09-30 12:57 -0700
SubjectDo I really need a web framework?
Message-ID<f4a6d31f-cffe-4c03-9586-4f00f9037516@googlegroups.com>
I want to set up a very simple website, and I need to know if it is necessary to use a web framework (e.g. Django) to do basic interactive operations such as receiving input from the user, looking up a database and returning some data to the user.
I know that this is exactly the purpose of web frameworks, and that they work fine.
However, I read somewhere that for small projects such operations can be managed without a web framework, just by using Python with mod_python or with the CGI module. Is this correct? 

What do you suggest, keeping in mind that I am a newbie and that my website project would be very simple and very small?

Thanks

[toc] | [next] | [standalone]


#55114

FromTim Delaney <timothy.c.delaney@gmail.com>
Date2013-10-01 06:39 +1000
Message-ID<mailman.506.1380573585.18130.python-list@python.org>
In reply to#55108

[Multipart message — attachments visible in raw view] — view raw

On 1 October 2013 05:57, <dufriz@gmail.com> wrote:

> I want to set up a very simple website, and I need to know if it is
> necessary to use a web framework (e.g. Django) to do basic interactive
> operations such as receiving input from the user, looking up a database and
> returning some data to the user.
> I know that this is exactly the purpose of web frameworks, and that they
> work fine.
> However, I read somewhere that for small projects such operations can be
> managed without a web framework, just by using Python with mod_python or
> with the CGI module. Is this correct?
>
> What do you suggest, keeping in mind that I am a newbie and that my
> website project would be very simple and very small?
>

There is no *need* to use a web framework. But a web framework can make
things a lot easier for you.

Have a look at webapp2: http://webapp-improved.appspot.com/

Tim Delaney

[toc] | [prev] | [next] | [standalone]


#55123

FromJohn Gordon <gordon@panix.com>
Date2013-09-30 21:53 +0000
Message-ID<l2crsn$5th$1@reader1.panix.com>
In reply to#55108
In <f4a6d31f-cffe-4c03-9586-4f00f9037516@googlegroups.com> dufriz@gmail.com writes:

> I want to set up a very simple website, and I need to know if it is
> necessary to use a web framework (e.g. Django) to do basic interactive
> operations such as receiving input from the user, looking up a database
> and returning some data to the user.

No, it's not necessary.  But depending on how large your website is,
using a framework can end up being a lot less work than doing it from
scratch.

> What do you suggest, keeping in mind that I am a newbie and that my
> website project would be very simple and very small?

That depends on how you define "very simple" and "very small".

For example, how many different pages will your website have?

A login page?
A search entry page?
A search results page?
A help page?
An error page?
A logout page?
Any other pages?

I worked on a project that did its own web handling from scratch, and
frankly it was a nightmare.  But it wasn't a small project, so yours
might be doable.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [next] | [standalone]


#55128

Fromwaynejwerner@gmail.com
Date2013-09-30 15:16 -0700
Message-ID<c8322155-e0c8-4c57-bdcd-3eed02ee75e3@googlegroups.com>
In reply to#55108
On Monday, September 30, 2013 2:57:08 PM UTC-5, duf...@gmail.com wrote:
> I want to set up a very simple website, and I need to know if it is necessary to use a web framework (e.g. Django) to do basic interactive operations such as receiving input from the user, looking up a database and returning some data to the user.
> 
> I know that this is exactly the purpose of web frameworks, and that they work fine.
> 
> However, I read somewhere that for small projects such operations can be managed without a web framework, just by using Python with mod_python or with the CGI module. Is this correct? 
> 
> 
> 
> What do you suggest, keeping in mind that I am a newbie and that my website project would be very simple and very small?

If it's small you want, Flask has worked quite well for me. Here's an example:


from flask import Flask, render_template, redirect, request
from <yourstuff> import save_data, get_data
app = Flask(__name__)

@app.route('/')
def main():
    return render_template('index.html')


@app.route('/data', methods=['GET', 'POST'])
def data():
    if request.method == 'POST':
        save_data(request.form.get('data'))
    else:
        return render_template('data.html', data=get_data())


It doesn't take much to tack SQLAlchemy on top of that for data access, and a couple hundred lines will give you quite a lot of power.

HTH,
W

[toc] | [prev] | [next] | [standalone]


#55151

FromRoy Smith <roy@panix.com>
Date2013-09-30 21:00 -0400
Message-ID<roy-BEDA53.21004730092013@news.panix.com>
In reply to#55108
In article <f4a6d31f-cffe-4c03-9586-4f00f9037516@googlegroups.com>,
 dufriz@gmail.com wrote:

> I want to set up a very simple website, and I need to know if it is necessary 
> to use a web framework (e.g. Django) to do basic interactive operations such 
> as receiving input from the user, looking up a database and returning some 
> data to the user.
> I know that this is exactly the purpose of web frameworks, and that they work 
> fine.
> However, I read somewhere that for small projects such operations can be 
> managed without a web framework, just by using Python with mod_python or with 
> the CGI module. Is this correct? 
> 
> What do you suggest, keeping in mind that I am a newbie and that my website 
> project would be very simple and very small?
> 
> Thanks

"Need" is a very difficult concept to pin down.  At one level, no you 
don't need a framework.  There's nothing that a framework does that you 
can't do yourself. On the other hand, there's a lot that frameworks do 
for you that if you didn't get for free, you'd be forced to do yourself.

Something needs to accept connections on a socket, talk some HTTP to the 
thing on the other end, parse the presented URL, talk to your database, 
generate some HTML, etc.  I'm sure you *can* do all that, but my guess 
is most of it has little or nothing to do with your core application, so 
it's just extra work you need to do to get where you want to be.

There's lots of different frameworks.  Django is certainly one of the 
major ones.  It's very powerful, but it also has a bit of a steep 
learning curve (despite its excellent tutorial).  I've used Tornado as 
well; it seemed quite a bit simpler and probably a better place to start 
for a first project.  I'm sure other people will suggest some others.  
My recommendation is to read a bunch, pick one, and go with it.  Don't 
try to roll everything yourself.

There's a good (but, perhaps, outdated) list at 
https://wiki.python.org/moin/WebFrameworks.  Of the ones listed, the 
only one I would really argue against is Zoap.  As the wiki says, it is 
the granddaddy of all python web frameworks, but the world has figured 
out better ways to do things since then.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web