On Monday, September 30, 2013 2:57:08 PM UTC-5, [email protected] 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