Can anyone explains the basics of using python to create web-pages. How do I write the code? How do I use it on the server?
I just learned the basics of Python software programming and I'm thinking it can be a good idea to stick to the same language for web applications.
But where to start??? I can't find any good beginner tutorials.
Thanx,
Andreas
first don't use cgi mod, he is horribele and slow,
it's better to you use modpython.
www.modpython.org he is installed here but I don't know whitch handler is isntalled (the primary is but the publisher handler not) . just ntry with exemple .(the .htaccess exemple is good)
and django www.django.org is not installed so you must create your idmanager and etc...etc...
ask if you nedd help
a+++
If you know Python Programming Language than the best way to start is use python as a CGI .. and if you just want to jump directly on web prorgaming then Zope is pretty much good www.zope.org
hello.cgi
| Code: |
#!/usr/bin/env python
print "Content-type: text/plain\r\n\r\n",
print "Hello world"
|
| deepak wrote: |
If you know Python Programming Language than the best way to start is use python as a CGI .. and if you just want to jump directly on web prorgaming then Zope is pretty much good www.zope.org
hello.cgi
| Code: |
#!/usr/bin/env python
print "Content-type: text/plain\r\n\r\n",
print "Hello world"
|
|
Aah yes! Python cgi seems easy enough to use. But I wonder what is the normal working procedure for create homepages in this environment. I mean, how does it work with more complex sites. Should I put all coding in one huge file? Or can I import and use normal html-files?
And one thing I've been wondering about all the time: CAN I USE PYTHON CODE WITHIN MY PRESENT HTML FILE TO ADD DYNAMIC CONTENT? I mean something like <runpython=python.py?clock> to make a clock on my html homepage.
Well, I have so many questions and there seems to be very few answers to find on google 
Poke it over internet, Its quite is with complex html design. I just have design a python site and its using AJAX. PythonCGI can perform all operations like ASP and PHP, the idea is important i.e how you'd use python as cgi
see this http://www.cs.virginia.edu/~lab2q/lesson_1/
Okay... how do I configure my server to use .py files as cgi??? I have never been working with apache before so I have no clue at all. I search on the forum but I couldn't make the examples I found work.
Thanx
frihost server is already configured see this http://deepak.frih.net/cgi-bin/test_python.py
Try below
| Code: |
<Directory "Path to CGI-BIN">
AddHandler python-program .py
PythonHandler mptest
PythonDebug On
</Directory>
|
| deepak wrote: |
frihost server is already configured see this http://deepak.frih.net/cgi-bin/test_python.py
Try below
| Code: |
<Directory "Path to CGI-BIN">
AddHandler python-program .py
PythonHandler mptest
PythonDebug On
</Directory>
|
|
Thanks for you fast answer deepak! However one more question. In what way should I write the "Path to CGI-BIN". I have the htaccess in the cgi-bin directory. Should I start with my root directory "public_HTML/cgi-bin" or how does it work??? 
Use Full path .. like C:\Program Files\Apache\cgi-bin or /usr/htdocs/cgi-bin .. I am not sure with PythonHandler it should be mptest ..please verify it.
Forgive a newbie's stupidity. I can't make Python CGI work with FRIHOST!
In public_html/cgi-bin I have 2 files. ".htaccess" and "mptest.py".
In htaccess I have:
| Code: |
<Directory "/domains/andreas.frih.net/public_html/cgi-bin/">
AddHandler python-program .py
PythonHandler mptest
PythonDebug On
</Directory> |
In mptest.py:
| Code: |
#!/usr/bin/env python
print "Content-type: text/plain\r\n\r\n",
print "Hello world"
|
Here, the file doesn't work: http://www.andreas.frih.net/cgi-bin/mptest.py.
| Quote: |
| Internal Server Error |
What on earth am I doing wrong???
Please change the file permission ... now it should be 644 .. make it 755. you dont need addhandler on frihost, they have already configured in apache.
Best!
Great to see some python resources on frihost, Im new to it having only discovered python a few days ago and I'm already programming away, its a great language to just get right into. I'm working on a MUD type game that will be mostly text based, I can read the room and character data in no problems, I cant seem to find information on how to write to the files tho!
Hi.
Many ppl consider Diving Into Python ( http://www.diveintopython.org/ ) as the cooler python web-book for beginners out there. even thou the second part of the book deals with advanced topics , the first part is easy to follow.
If one is new to programming as well as to python, there's this nice tutorial called "python babysteps" here:
http://coolnamehere.com/geekery/python/pythontut.html
Rock on,
Jay
Python is quite flexible and its much better in application designing .. its quite easy and lots of open source help 