[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: Do I really need a web framework?
From: waynejwerner () gmail ! com
Date: 2013-09-30 22:16:12
Message-ID: c8322155-e0c8-4c57-bdcd-3eed02ee75e3 () googlegroups ! com
[Download RAW message or body]
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
--
https://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic