top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Do I really need a web framework?

+1 vote
851 views

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?

Any suggestions?

posted Sep 30, 2013 by Bob Wise

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
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/

2 Answers

+1 vote
 
Best answer

"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.

answer Oct 1, 2013 by Anderson
+1 vote

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.

answer Sep 30, 2013 by Seema Siddique
Similar Questions
+1 vote

I would like to create a web app using flask or cgi library (python) along with telnetlib to telnet to specific servers and execute commands and retrieve the output. The output will then be formatted and outputted to a webpage .

Is this the best way of getting info from a remote system to be output to a web page? Is flask over kill for project like this ?

+1 vote

I want to count the number of active user in website and also I have to display their IP Address by using python Django framework.

+1 vote

I have a python script (web service with query postgresql/postgis). Up to now, i did several test on my local laptop station (windows).

Now i want to execute this python script on our remote server (Web server : Apache;OS : Linux).

How to write a CGI template please? Can someone help me?

+1 vote
avinash@dell ~ $ sudo pip install django-tracking

Downloading/unpacking django-tracking
Downloading django-tracking-0.4.1.tar.gz (1.9MB): 1.9MB downloaded
Running setup.py (path:/tmp/pip_build_root/django-tracking/setup.py) egg_info for package django-tracking
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip_build_root/django-tracking/setup.py", line 6, in
import tracking
File "tracking/__init__.py", line 1, in
import listeners
File "tracking/listeners.py", line 6, in
from django.core.cache import cache
File "/usr/local/lib/python2.7/dist-packages/django/core/cache/__init__.py", line 34, in
if DEFAULT_CACHE_ALIAS not in settings.CACHES:
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 46, in __getattr__
self._setup(name)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 40, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 17, in

File "/tmp/pip_build_root/django-tracking/setup.py", line 6, in

import tracking

File "tracking/__init__.py", line 1, in

import listeners

File "tracking/listeners.py", line 6, in

from django.core.cache import cache

File "/usr/local/lib/python2.7/dist-packages/django/core/cache/__init__.py", line 34, in

if DEFAULT_CACHE_ALIAS not in settings.CACHES:

File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 46, in __getattr__

self._setup(name)

File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 40, in _setup

% (desc, ENVIRONMENT_VARIABLE))

django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

+4 votes

I am getting the following error -

UserProfile.picture: (fields.E210) Cannot use ImageField because Pillow is not installed.

HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip install pillow".
System check identified 1 issue (0 silenced).

This is installation Summary of pillow

PIL SETUP SUMMARY
version Pillow 2.6.1
platform linux 3.4.2 (default, Oct 8 2014, 13:08:17) [GCC 4.9.1]

--- TKINTER support available
--- JPEG support available
--- OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
--- LIBTIFF support available
--- FREETYPE2 support available
--- LITTLECMS2 support available
--- WEBP support available
--- WEBPMUX support available
...