Do I really need a web framework?

D

dufriz

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
 
T

Tim Delaney

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
 
J

John Gordon

In said:
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.
 
W

waynejwerner

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
 
R

Roy Smith

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top