Django Python Primer Tutorial

Django Python Primer Tutorial

Django Python Primer Tutorial

Django is a high-level Web framework that utilizes the Python programming language. You may remember from some time back with Python Webserver Primer Tutorial as shown below, that we intimated we would try this out sometime. Django helps you achieve rapid, clean, pragmatic design and development of web apps, with all those advantages Python offers.

As one of the Three P’s you’d expect Python to be capable of this, and, indeed, it can be a complete replacement for PHP as your server-side language. It is growing in popularity, and can see its appeal for the clear-thinkers amongst us. Its data structures are appealing to many programmers, and with more and more Python code written, the more powerful it will become in the Open Source world. So combine this with Django’s web app interfacing to databases (SQLite (database) is installed when you install Django, and you can interface to others, such as PostgreSQL or MySql) and you have a great environment to make powerful and interesting web apps.

Today we install Django to a pre-existant Python installation that sits happily alongside a local MAMP Apache/PHP web server without concern. If you do this yourself, too, please head for the latest version, because there have been recent security patch improvements to Django. We follow the Django website’s first tutorial to do a small “poll” web app which we call “mysite” as you would if “yer head’s a marley” (as they used to say in Coleraine). Along the way you’ll see a Django HTTP://localhost:8080 local web server we’ll add to the web server list in Cassini++ WebServer Primer Tutorial.

Lots of sidetracks here but hope you’ll bear with the mistakes, and if you are beginning, perhaps, sidestep those mistakes.


Previous relevant Python Webserver Primer Tutorial is shown below.

Python Webserver Primer Tutorial

Python Webserver Primer Tutorial (try twirling round bottom of image for a synopsis ... 'do the twirl now')

Today’s tutorial shows yet another approach regarding the creation of a local Web Server. Today we create a very simple Python Web Server, and give thanks to Python and XML by Christopher A. Jones and Fred E. Drake, for the excellent “basis” code on pp 198-200. This tutorial could use Go Webserver Primer Tutorial as shown below, for compare and contrast purposes, and you may want to refer to our growing list of Web Server ideas at Cassini++ WebServer Primer Tutorial and perhaps Web Server Primer Tutorial and maybe Apache WebServer on Mac and The Three P’s Primer Tutorial.

As one of the Three P’s you’d expect Python to be capable of this, and, indeed, it can be a complete replacement for PHP as your server-side language. Believe it is growing in popularity, and can see its appeal for the clear-thinkers amongst us. Its data structures are appealing to many programmers, and with more and more Python code written, the more powerful it will become in the Open Source world.

So this Python’s Web Server “ingredients” (ie. methods) for class ourRequestHandler are:

  • do_GET helps with GET requests
  • do_POST helps with POST requests
  • ourPrintBrowserHeaders prints HTTP headers
  • ourPrintCustomHTTPResponse takes response and sends code and custom headers back to browser

Link to downloadable Python programming source code for a rudimentary webserver could be called PythonHTTPServer.py (which oversees the “POST” test HTML ourTestFormPage.html) as you wish.

Are you looking for a commercial Python web framework? You could try Django.

Will leave you with a chuckle, m’lord.


Previous compare and contrast Go Webserver Primer Tutorial is shown below.

Go Install Primer Tutorial

Go Webserver Primer Tutorial

Did you wake up wanting to write your own Web Server? No? Well, what are WE to do with YOU? “Lefty? Mugsy? Priscilla? Let ‘em ‘av it? Yes, the web server, you ‘eard what oi said! Sorry, you’re having lunch?”

… four hours later …

“Mugsy, what’s that triangular piece of paper … never mind … have you got that web server?”

(Metallic tinkering sound)

“You do know what a web server is, don’t you? What’s that you’ve got there on that silver thing behind your back?”

(Metallic tinkering sound) … replaced by (Metallic sounds that are tinkering)

“Lefty, do you know what is behind Mugsy’s back … and why have you got one of those triangular pieces of pap … oh, never mind. Is that a link you want me to click?”

.

.

.

.

.

.

.

.

V

Welcome to Mugsy’s and Lefty’s personalized link

Our tutorial today builds on previous Go Install Primer Tutorial as shown below.

Link to downloadable Go programming source code for a rudimentary webserver (about animals) could be called webserver.go as you wish.

Link to Go “spiritual home” at Google.

Link to really good Go tutorials at Google.

Link to Go 1.1 Google Open Source Blog is here.

Link to really good Go web information at Google.


Previous Go Install Primer Tutorial is shown below.

Go Install Primer Tutorial

Go Install Primer Tutorial (try twirling round bottom of image for a synopsis ... 'do the twirl now')

Go (by Google) gave me that feeling like you are just seeing the tip of the iceberg, again. A friend kindly put me onto this as a programming language which is an alternative to OOP but not just a function call type of language.

Here we just install it (on a Mac 64bit laptop with Mac OS X 10.7.5) and do the old “Hello World“, but we will explore more in tutorials to come, and in any case here we do 4 x “hello world” with 3 different programs. Meanwhile, have a read from Wikipedia about it, below:

Go, otherwise known as Golang, is an open source, compiled, garbage-collected, concurrent system programming language. It was first designed and developed at Google Inc.[7] beginning in September 2007 by Robert Griesemer, Rob Pike, and Ken Thompson.[3]

The language was officially announced in November 2009 and is now used in some of Google’s production systems.[8] Go’s “gc” compiler targets the Linux, Mac OS X, FreeBSD, OpenBSD, Plan 9, and Microsoft Windows operating systems and the i386, amd64, and ARM processor architectures.[9]

You can download go (2009) programming source codes and rename to hello.go, helloworld.go, slice.go.

Link to Go “spiritual home” at Google.

Link to really good Go tutorials at Google.

Link to Go 1.1 Google Open Source Blog is here.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in Database, eLearning, Tutorials and tagged , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>