Welcome back to the Creativity and Computation LAB - PowerPoint PPT Presentation

1 / 44
About This Presentation
Title:

Welcome back to the Creativity and Computation LAB

Description:

Continued work on the Python tutorial. An introduction to running CGI scripts ... Also note that the file has '.pyhp' appended instead of just '.py' ... – PowerPoint PPT presentation

Number of Views:77
Avg rating:3.0/5.0
Slides: 45
Provided by: Dell525
Category:

less

Transcript and Presenter's Notes

Title: Welcome back to the Creativity and Computation LAB


1
Welcome back to theCreativity and
ComputationLAB!
2
This weeks class will be incredible!
3
Please calm down, we know you are excited.
4
We will spend todays session going over three
things
  • Continued work on the Python tutorial
  • An introduction to running CGI scripts
  • Embedding Python within HTML scripts

5
Next week we will have a break from coding and go
through a session on podcasting and RSS.
6
First, a reminder.If you have a laptop, please
being it to CC Lab when possible.
7
There are two reasons for bringing a laptop to
class
  • If you have a Mac, you can do all of the stuff we
    are doing on lta.parsons.edugt locally
  • You can save all of the files, scripts, and
    programs we use to your own machine

8
We really urge you to take advantage of the Mac
OS X if you can. Or figure out how to do this
stuff on Windows.Set it up on your own machine!
(Youll learn more.)
9
We realize that there was a lot of info in the
Python tutorial. Lets take a moment to go
around the room and let people tell where they
are at, and talk about what functional Python
script they wrote (or didnt write).
10
You will have the next couple of weeks to
continue learning about Python.
11
Remember, try to write something that is
functional. You will find many ways to apply
tools like Python to your everyday design work.
Pick a small problem that you think Python might
solve, and give it a shot.
12
We will schedule an evening or weekend Python
workshop if there is the need/demand.Speak up!
13
We are going use Python to create web pages.We
will do this by using a Python HTML
preprocessor.
14
There are like 7 trillion different types of
preprocessors in the world. Some create HTML,
many do other things.
15
Preprocessor is a good word to know. If you are
engaged in small talk with someone you dont
like, simply saypreprocessor(They will
depart immediately)
16
Anyway, basically all of this happens by
embedding Python code into HTML.The Python
code is executed using a basic web server
technology called CGI.
17
Many of you may have worked with CGI in the past.
It is the technology used to process HTML Forms.
18
First we need to make sure that CGI is set up and
working on your lta.parsons.edugt account.
19
Do this by creating the directory cgi-bin
within your public_html directory, if it isnt
already there.
20
Then check the permissions on the CGI directory
(use the command ls -l to do this. The results
should read something likedrwxr-xr-x 2 sven
staff 4096 Sep 13 1214 cgi-bin
21
If your cgi-bin doesnt have the
permissionsdrwxr-xr-xA quick way to change
the permissions to the correct setting ischmod
755 cgi-bin
22
We told you last week that you would be checking
and changing the permissions on your web files a
lot. This is a good example. If a folder isnt
readable or executable, things wont work
right.
23
When you have the cgi-bin folder set up right,
you want to test it with a script.Go to the lab
site and access the CGI test script.
24
Open a new text file (use the text editor nano)
in your lta.parsons.edugt server account, name it
tester.cgi, and type in the contents of that
file.
25
Save the file astester.cgiinto your cgi-bin
directory.
26
Save the file astester.cgiinto your cgi-bin
directory.
27
We are asking you to do it this way (instead of
just cutting and pasting) to make sure there are
no invisible characters in the file. Its
also good practice on using Unix text editors.
28
Try running the file by going to the
URLhttp//a.parsons.edu/username/cgi-bin/test
er.cgi If the CGI is working, ou should get a
page that says TEST
29
Go in and mess around with the contents of your
tester.cgi file. Make it say something else.
30
This test CGI file is calling a language called
Perl. You can tell what language a cgi file
is calling by looking at the sh-bang (!) line,
usually the first line of a cgi file.
31
We wont be using Perl in CC Lab, but it is a
very common, very powerful scripting language in
use all over the web.
32
Python will use CGI in exactly the same way as
the tester.cgi file used Perl. Basically, we
will create a HTML file, which will in turn call
a Python file which will be present in the
cgi-bin folder.
33
We will be working with a Python preprocessor
calledPyHP(The link to the developers site
is on the CC Lab site)
34
Go to the CC Lab site and download the PyHP tar
fileto your local machine.
35
Now upload it to your cgi-bin directory (using
secure ftp, or sftp)Then uncompress itgunzip
PyHP.tgz Then untar ittar -xf PyHP.tar
36
Once youve done all of this there will be a
PyHP directory within your cgi-bin
directory.There is a file within that directory
called pyhp.py. Thats the main file we will be
using.
37
Also in that directory you will find a sample
directory, which contains a test file.Our
challenge is to get that test file to work.
38
Notice that the sh-bang line in that file is
not quite the same as the earlier one that called
Perl.You must always include the full path to
your pyhp.py file.
39
Also note that the file has .pyhp appended
instead of just .py. This is a must for files
using PyHP.
40
You can go to the PyHP site (link on the CC Lab
site), and review the (rather brief)
documentation.
41
We will be running PyHP as stand alone (using
CGI).
42
Your assignment this week is to get this test
PyHP file to run on your lta.parsons.edugt web
site.Change the path to your path (replace Ben
Bacons path)
43
One final noteThere are actually two
development projects out there called PyHP. Use
the one linked to on the CC Lab site, developed
byChristopher A. Craig
44
Good Luck!
Write a Comment
User Comments (0)
About PowerShow.com