473,698 Members | 2,630 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

where do I begin with web programming in python?

I have been to the main python site, but am still confused. I have
been using .net, so it may be obvious how to do this to everyone
else. I am aware there are various frameworks (Django, Pylons, etc.),
but I would like to know how to create web pages without these. If I
have mod_python or fastcgi on apache, where do I start? I don't have
clue where to begin to create a web page from scratch in python. I am
sure I will want to access database, etc., all the "normal" stuff, I
just want to do it myself as opposed to the frameworks, for learning.

Thank you for any help.
Jun 27 '08 #1
8 1581
On May 1, 4:25*pm, jmDesktop <needin4mat...@ gmail.comwrote:
I have been to the main python site, but am still confused. *I have
been using .net, so it may be obvious how to do this to everyone
else. *I am aware there are various frameworks (Django, Pylons, etc.),
but I would like to know how to create web pages without these. *If I
have mod_python or fastcgi on apache, where do I start? *I don't have
clue where to begin to create a web page from scratch in python. *I am
sure I will want to access database, etc., all the "normal" stuff, I
just want to do it myself as opposed to the frameworks, for learning.

Thank you for any help.
The web frameworks make it a lot easier. But you can use the httplib
modules. You should check out the wiki: http://wiki.python.org/moin/WebProgramming

There's also a couple of books on the topic: "Python Web Programming"
by Steve Holden, and "Web Programming in Python" by Thiruvathukal.

Check out the cgi-type stuff especially.

Hope that helps some.

Mike
Jun 27 '08 #2
jmDesktop schrieb:
I have been to the main python site, but am still confused. I have
been using .net, so it may be obvious how to do this to everyone
else. I am aware there are various frameworks (Django, Pylons, etc.),
but I would like to know how to create web pages without these. If I
have mod_python or fastcgi on apache, where do I start? I don't have
clue where to begin to create a web page from scratch in python. I am
sure I will want to access database, etc., all the "normal" stuff, I
just want to do it myself as opposed to the frameworks, for learning.
I highly recommend WSGI instead of mod_python or (fast)cgi. I've heard
only bad things about mod_python over the past years and CGI is totally
old school.

Check out Python Paste, CherryPy and Django. You can also try the Zope,
Zope3 and Plone world but Zope is usually for larger and complex
applications.

Most frameworks come with their own little web server for development, too.

Christian
Jun 27 '08 #3
On May 2, 7:45 am, Christian Heimes <li...@cheimes. dewrote:
jmDesktop schrieb:
I have been to the main python site, but am still confused. I have
been using .net, so it may be obvious how to do this to everyone
else. I am aware there are various frameworks (Django, Pylons, etc.),
but I would like to know how to create web pages without these. If I
havemod_pythono r fastcgi on apache, where do I start? I don't have
clue where to begin to create a web page from scratch in python. I am
sure I will want to access database, etc., all the "normal" stuff, I
just want to do it myself as opposed to the frameworks, for learning.

I highly recommend WSGI instead ofmod_pythonor (fast)cgi. I've heard
only bad things aboutmod_python over the past years and CGI is totally
old school.

Check out Python Paste, CherryPy and Django. You can also try the Zope,
Zope3 and Plone world but Zope is usually for larger and complex
applications.

Most frameworks come with their own little web server for development, too.
I'd also suggest avoiding coding anything directly to mod_python and
instead base things on WSGI. You can still run it on mod_python with a
suitable adapter, but you can also run it with mod_wsgi, mod_fastcgi,
or using pure Python web servers such as the one in Paste as well.

For a low level nuts and bolts (anti framework) approach I'd suggest
looking at:

http://dev.pocoo.org/projects/werkzeug/

This gives you all the basic components, but it is really up to you as
to how you put them together, which seems to be what you want to be
able to do.

Graham

Jun 27 '08 #4
On May 1, 7:13*pm, Graham Dumpleton <Graham.Dumple. ..@gmail.com>
wrote:
On May 2, 7:45 am, Christian Heimes <li...@cheimes. dewrote:
jmDesktop schrieb:
I have been to the main python site, but am still confused. *I have
been using .net, so it may be obvious how to do this to everyone
else. *I am aware there are various frameworks (Django, Pylons, etc.),
but I would like to know how to create web pages without these. *If I
havemod_pythono r fastcgi on apache, where do I start? *I don't have
clue where to begin to create a web page from scratch in python. *I am
sure I will want to access database, etc., all the "normal" stuff, I
just want to do it myself as opposed to the frameworks, for learning.
I highly recommend WSGI instead ofmod_pythonor (fast)cgi. I've heard
only bad things aboutmod_python over the past years and CGI is totally
old school.
Check out Python Paste, CherryPy and Django. You can also try the Zope,
Zope3 and Plone world but Zope is usually for larger and complex
applications.
Most frameworks come with their own little web server for development, too.

I'd also suggest avoiding coding anything directly to mod_python and
instead base things on WSGI. You can still run it on mod_python with a
suitable adapter, but you can also run it with mod_wsgi, mod_fastcgi,
or using pure Python web servers such as the one in Paste as well.

For a low level nuts and bolts (anti framework) approach I'd suggest
looking at:

*http://dev.pocoo.org/projects/werkzeug/

This gives you all the basic components, but it is really up to you as
to how you put them together, which seems to be what you want to be
able to do.
Or if you don't want to use any 3rd party package and have Python 2.5,
you may start from http://www.xml.com/pub/a/2006/09/27/...eb-weapon.html.
Here's the standard "Hello world!" example:

from wsgiref.simple_ server import make_server

def application(env iron, start_response) :
start_response( '200 OK',[('Content-type','text/html')])
return ['<html><body>He llo World!</body></html>']

httpd = make_server('', 8000, application)
print "Serving HTTP on port 8000..."
httpd.serve_for ever()

and point your browser to http://localhost:8000/

HTH,
George
Jun 27 '08 #5
jmDesktop <ne***********@ gmail.comwrites :
I am aware there are various frameworks (Django, Pylons, etc.),
but I would like to know how to create web pages without these. If I
have mod_python or fastcgi on apache, where do I start? I don't have
clue where to begin to create a web page from scratch in python. I am
sure I will want to access database, etc., all the "normal" stuff, I
just want to do it myself as opposed to the frameworks, for learning.
I didn't notice anyone mentioning the simplest answer of them all:
write an old fashioned cgi using python's cgi module.
Jun 27 '08 #6
On May 1, 3:25*pm, jmDesktop <needin4mat...@ gmail.comwrote:
I have been to the main python site, but am still confused. *I have
been using .net, so it may be obvious how to do this to everyone
else. *I am aware there are various frameworks (Django, Pylons, etc.),
but I would like to know how to create web pages without these. *If I
have mod_python or fastcgi on apache, where do I start? *I don't have
clue where to begin to create a web page from scratch in python. *I am
sure I will want to access database, etc., all the "normal" stuff, I
just want to do it myself as opposed to the frameworks, for learning.

Thank you for any help.
Directions for a simple CGI script:

1) Start apache.

2) Use a text editor to create a webpage with a link:

<html>
<head>
<title>Python CGI Test</title>
</head>

<body>
<div>
<a href="http://localhost/cgi-bin/first.py">click me</a>
</div>
</body>

</html>

Save that file with a .htm extension anywhere on your computer, e.g.
name the file test.htm and save it in C:\My Documents.
3) The value of the link's href attribute is a special url. The url
starts with "http://localhost", or it may need to start with something
like http://localhost:8080" depending on what port number you
installed Apache on. If you used the default port when you installed
Apache, then the first part of the url will be "http:/localhost".

The rest of the url is the relative path to your cgi script. The path
is relative to your Apache2 folder. For instance, my directory
structure looks like this:

Apache2
----htdocs
----cgi-bin
--------first.py
----etc.

So the relative path to my cgi script is "/cgi-bin/first.py".

4) Create a cgi script:

#!/usr/bin/env python

#For Windows, instead of the above line use
#something like: #!C:\Python25\p ython.exe
#instead. The path after "#!" should be the
#path to wherever python.exe is on your computer.

import cgitb; cgitb.enable()

#The above line will cause error messages to
#be sent to your browser, which is helpful for
#debugging. Otherwise, your browser will just
#show a blank page when there is an error in your
#script

print "Content-type: text/html"
print
print "<h1>Hello World</h1>"
The first print statement is the minimum header you need when
responding to a web page. After you print all the headers you desire,
then you need to print a blank line. After the blank line, you print
the html that you want the browser to display.
5) On Unix: you have to set the file permissions for your cgi script.
Everyone must be able to read and execute your cgi script:

$ chmod 755 first.py
6) Start your web browser, and click on File>Open and navigate to
your .htm file. When your html page opens in your browser, click on
the link. The link will call your python cgi script, the cgi script
will respond my sending some html to your browser, then your browser
will display the html.
Jun 27 '08 #7
On May 2, 10:07*am, bvidinli <bvidi...@gmail .comwrote:
i also asked same question in this list last week.
i foundhttp://www.cherrypy.or g/to be most suitable for me.
it is basic, easy, pure...
it contains its own webserver, very easy to start.

others have many framworks, structures, classes many many..
i wanted a pure web programming system , i found cherrypy.

see you.

2008/5/2 jmDesktop <needin4mat...@ gmail.com>:
I have been to the main python site, but am still confused. *I have
*been using .net, so it may be obvious how to do this to everyone
*else. *I am aware there are various frameworks (Django, Pylons, etc..),
*but I would like to know how to create web pages without these. *IfI
*have mod_python or fastcgi on apache, where do I start? *I don't have
*clue where to begin to create a web page from scratch in python. *Iam
*sure I will want to access database, etc., all the "normal" stuff, I
*just want to do it myself as opposed to the frameworks, for learning.
*Thank you for any help.
*--
*http://mail.python.org/mailman/listinfo/python-list

--
Ý.Bahattin Vidinli
Elk-Elektronik Müh.
-------------------
iletisim bilgileri (Tercih sirasina gore):
skype: bvidinli (sesli gorusme icin,www.skype.com)
msn: bvidi...@iyibir isi.com
yahoo: bvidinli

+90.532.7990607
+90.505.5667711
I agree. Try cherrypy. I was able to write simple issue tracking
system for my project with basic web interface within 2 weeks.
Prior to this I had no web development experience at all. It was
really easy with cherrypy to start.
Jun 27 '08 #8
CM
On May 2, 10:18 am, "andrei.zavi... @gmail.com"
<andrei.zavi... @gmail.comwrote :
On May 2, 10:07 am, bvidinli <bvidi...@gmail .comwrote:
i also asked same question in this list last week.
i foundhttp://www.cherrypy.or g/tobe most suitable for me.
it is basic, easy, pure...
it contains its own webserver, very easy to start.
others have many framworks, structures, classes many many..
i wanted a pure web programming system , i found cherrypy.
see you.
2008/5/2 jmDesktop <needin4mat...@ gmail.com>:
I have been to the main python site, but am still confused. I have
been using .net, so it may be obvious how to do this to everyone
else. I am aware there are various frameworks (Django, Pylons, etc.),
but I would like to know how to create web pages without these. If I
have mod_python or fastcgi on apache, where do I start? I don't have
clue where to begin to create a web page from scratch in python. I am
sure I will want to access database, etc., all the "normal" stuff, I
just want to do it myself as opposed to the frameworks, for learning.
Thank you for any help.
--
http://mail.python.org/mailman/listinfo/python-list
--
Ý.Bahattin Vidinli
Elk-Elektronik Müh.
-------------------
iletisim bilgileri (Tercih sirasina gore):
skype: bvidinli (sesli gorusme icin,www.skype.com)
msn: bvidi...@iyibir isi.com
yahoo: bvidinli
+90.532.7990607
+90.505.5667711

I agree. Try cherrypy. I was able to write simple issue tracking
system for my project with basic web interface within 2 weeks.
Prior to this I had no web development experience at all. It was
really easy with cherrypy to start.

Really? I tried CherryPy for a few minutes--totally 100% new to
web programming--and though I was pleased at the very basic "Hello,
World!" tutorial, I was unable to figure out how to use the more
advanced tutorials that come with the package. Could you suggest
how one could learn? I have experience with Python and GUI app
development, zero on web apps, but want to make widget-having web
apps which uses Python as the logic.

Any tips would be appreciated!

Also, beyond just running a small test web app with the "server"
running on my own computer, what is a basic way to try it out
actually on the web? Thanks!
Jun 27 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
1505
by: Richard | last post by:
Just downloaded python for the fun of it. What do I run to begin coding with? Version 2.3.3 When I run the "command line" thing, I get a dos window. Now what? The built in tutor explains some basics about programming but zilch on where to begin.
3
1388
by: Samuel Walters | last post by:
I'm currently considering a position teaching math and possibly programming at a small local magnet school. If I was also teaching programming, I would, of course, be using Python. So, I went out and googled around for resources. I found lots of articles about using Python to teach programming, but I have yet to turn up one forum where teachers using Python talk amongst themselves. Can anyone point me to such a resource, or, at least...
1
1979
by: mirandacascade | last post by:
Version of python: 2.4 O/S: Win2K I will be writing some python scripts to do some client-side programming that involves socket.py. I expect that I will be making calls to the following methods/functions: connect_ex() setsockopt() sendall()
3
1180
by: dutche | last post by:
Hi, I'm new in Python and I'm learning with "Learning Python" oreilly's book which is very good written and explanatory. Now, that I know a bit of Python, I want to make some simple project, I thought something like a menu, just like "kxdocks" menu or something like that, with transparency and all with xml. But I dont know what things I have to know. PyGame is in it, right?
23
2391
by: gord | last post by:
As a complete novice in the study of Python, I am asking myself where this language is superior or better suited than others. For example, all I see in the tutorials are lots of examples of list processing, arithmetic calculations - all in a DOS-like environment. What is particularly disappointing is the absence of a Windows IDE, components and an event driven paradigm. How does Python stand relative to the big 3, namely Visual C++,...
11
1525
by: Mister Newbie | last post by:
I have no programming experience. I want to learn Python so I can make simple, 2D games. Where should I start? Can you recommend a good book? Thank you.
33
2130
by: NicolasG | last post by:
Hi, I want to be a professional python programmer, unfortunately I'm working on technical support and don't have the time/patience to start making projects my self. I tried to apply to some Python positions but unfortunately sometimes to work as a programmer is really hard in this world, every employee requires professional experience and you can't really start as a beginner.. I'm planning to save some money and attend a course in any...
8
1524
by: Edward Cormier | last post by:
Which computer books are the best to begin learning Python 2.5 with? I've heard that Learning Python 3rd Edition is a good choice - can anyone give any more advice on this? Thanks.
6
6683
by: cj007541 | last post by:
Hey guys, My names Casey. Im 17 and going to be a senior in high school this year. I have already taken a school class in python and it was a really big help for me as it taught me a lot more then i would have been able to figure out on my own. It was nice being able to have a teacher there that i could talk and ask questions to. It was also great to be able to work with some kids my age that were into programming like me. We were able to...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.