For 2023 - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.
Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!
I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Python module Y202
Python on the Web
Exercises, examples and other material relating to training module Y202. This topic is presented on public courses Learning to program in Python
, Python Programming
Python is an excellent language for text string handling, doing exactly what's required of a language that's to be used on your Web server, to read and filter user inputs, and to return Web pages in response.
Related technical and longer articlesNasty Characters in Web Applications
|Articles and tips on this subject||updated|
|4536||Json load from URL, recursive display, Python 3.4|
Reading a json object from a remote URL (or it that's not available from a local file), displaying the contents of the object, modifying it, and printing it out. A Python 3.4 example from today's Python course. See [here] for full source code.
Note that in Python 2, you would have used urllib2 which ...
|4404||Which (virtual) host was visited? Tuning Apache log files, and Python analysis|
We host a number of domains on our main server, and in order to avoid fragmentation of log files, we keep a sinle composite log. Rather than use a standard logfile format henceforth, I've changed the second field to carry the virtual host name accessed for the request, as that was missing up until this ...
|4089||Quick and easy - showing Python data hander output via a browser|
From today's intermediate Python course - a new example of how to very quickly present the results of running an application on the web - [here].
The objective was to provide an almost-trivial way of letting results be viewed via a remote browser. No forms, no validation needed, no formatting of the ...
|1745||Moodle, Drupal, Django (and Rails)|
In the 1970s, we had C and in that decade and the following one, we put together our systems in that language and its derivatives.
In the 1990s, we had Perl and in that decade and the following one, we put together our systems in that language are related ones.
In the 2010s, we'll have a wide range ...
|2365||Counting Words in Python via the web|
I love writing things in Python - it's a great language for achieving a great deal in a short time. And it works well got Simple CGI scripts.
Today's challenge - to count the number of words (and number of DIFFERENT words) in a piece of text, so give an idea of how much work would be involved in translating ...
|2238||Handling nasty characters - Perl, PHP, Python, Tcl, Lua|
Are your writing or maintaining a web based application that uses forms? If so, you have better be aware of some of the nasty characters that are around!
The < character, when echoed back from a users's input 'unchallenged', may form the start of a tag. So that in a relatively benign case, a user ...
|433||FTP - how to make the right transfers|
If you're transfeerring files from one computer to another, you'll probably use an FTP client program - either something with a GUI or the FTP command itself on your local machine, and that will talk to an FTP daemon on the server.
It's important to note that you need to navigate to the right directory ...
|426||Robust checking of data entered by users|
10 steps to testing the bullet proofing user inputs or how to avoid being caught by nasties when your script goes live!
1. Test it works with intended entries. It's not going to be much good if it falls over when someone entered a valid piece of data!
2. Test it works (fails correctly) with erroneous ...
|903||Pieces of Python|
From a most interesting Saturday which was spent doing a one on one session on thread, wxPython, etc - some Python snippets that provide unusual demos and hard-to-find answers:
The Backtic operator evaluates an expression and returns the result as a string
val1 = 16
val2 = 18
result = "The result ...
|237||Crossfertilisation, PHP to Python|
Rasmus Lerdorf's "Do you PHP" talk on our Geek Cruise last October was brilliant - I heard so much about what's behind PHP and how its originator intends it to be used that it give me a real strong understanding of best practise - you'll find further details availble here and elsewhere on this site.
Examples from our training material
|hsapp1.py|| Web application mark 1 - 3 pages, sessions, hidden fields|
|hsapp2.py|| Web application, Mark 2 - 3 pages, sessions, hidden fields|
|hsdemo.htp|| Template for hsapp1 and hsapp2|
|inf.py|| Simple web demo - produce form, complete form, act on data entered to form|
|jhandle|| Python 3.4 urllib urlopen and json|
|martin.html|| Translation coster - HTML form|
|martin.py|| Translation coster - CGI script|
|piddle.py|| CGI, Python, Web server, HTML - reporting server time|
|place.py|| Python / CGI - read from a form, run an application, fill in a template to respond|
|pybrow|| Browser client|
|pyhello|| Embedding plain text app on the web|
|pyserv|| basic web server|
|python_mysql_web.py|| Python, MySQL, CGI (Web) board|
|pytop|| Analysis of current web log file|
|tellmewhen.py|| Running a Python program through CGI|
|template.htp|| Template for simple web example|
|visitor.py|| Analysing a web access log file|
PicturesRe-using HTML templates and web helpers for efficient coding
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from [here]
Topics covered in this module
Introduction to Python on the Web.
Reading from a form, using templates, other techniques.
Web and Python subjects - state, security, modPython etc..
Where does my Python run?.
How do I link pages together?.
What about security considerations?.
Can I make the Python run more efficiently on the Web?.
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre.