Jump to content


Photo

Chapter 7 Page 240 Simple_httpd.py To Server.py


  • Please log in to reply
5 replies to this topic

#1 Charly2001

Charly2001

    Active Member

  • Members
  • PipPip
  • 12 posts
  • Gender:Male
  • Location:Québec, Canada
  • Interests:Linux; Ubuntu 12.04

    anything Python

Posted 23 January 2014 - 06:53 AM

Unable to get Coach Kelly's Website running ? ? ? I 've been at it many many days

1) The modules athletemodel.py & yate.py running fine on their own

2) Ubuntu 12.04 (I figured: might as well learn python on a Linux system) Its not my first time either with python or on Ubuntu.

3) python3.2 yes the executable bits are set

When I try to run generate_list from my Browser (on http://localhost:8080) i get this error message

Traceback (most recent call last):
File "/usr/lib/python3.2/http/server.py", line 1110, in run_cgi
os.execve(scriptfile, args, env)
OSError: [Errno 13] Permission denied
localhost - - [23/Jan/2014 09:39:39] CGI script exit status 0x7f00

Any ideas please let me know

THANKS

#2 paulbarry

paulbarry

    Advanced Member

  • O'Reilly Author
  • PipPipPipPipPipPipPipPip
  • 307 posts

Posted 23 January 2014 - 07:45 AM

Can you upload (inside the <> tags) the code that you are trying to run?

Thanks.

--Paul.

#3 Charly2001

Charly2001

    Active Member

  • Members
  • PipPip
  • 12 posts
  • Gender:Male
  • Location:Québec, Canada
  • Interests:Linux; Ubuntu 12.04

    anything Python

Posted 23 January 2014 - 12:27 PM

Can you upload (inside the <> tags) the code that you are trying to run?

Thanks.

--Paul.


Hi Paul Totaly LOVE your Book.

I have attached my code for generate_list.py & generate_timing_data.py Of course ** server.py ** is supplied by Python3.2/HTTP/

generate_list is launched by clicking on Coach Kelly's Website

**************************** generate_list.py
#! /usr/lib/python3.2

import cgitb
cgitb.enable()

import glob

import athletemodel
import yate

data_files = glob.glob("data/*.txt")
athletes = athletemodel.put_to_store(data_files)

print(yate.start_response())
print(yate.include_header("Coach Kelly's List of Athletes"))
print(yate.start_form("cgi-bin/generate_timing_data.py"))
print(yate.para("Select an athlete from the list to work with:"))
for each_athlete in athletes:
print(yate.radio_button("which_athlete", athletes[each_athlete].name))
print(yate.end_form("Select"))
print(yate.include_footer({"Home": "/index.html"}))

*********************************** generate_timing_data.py

#! /usr/lib/python3.2

import cgi

import cgitb
cgitb.enable()

import athletemodel
import yate

athletes = athletemodel.get_from_store()

form_data = cgi.FieldStorage()
athlete_name = form_data['which_athlete'].value

print(yate.start_response())
print(yate.include_header("Coach Kelly's Timing Data"))
print(yate.header("Athlete: " + athlete_name + ", DOB: " +
athletes[athlete_name].dob + "."))
print(yate.para("The top times for this athlete are:"))
print(yate.u_list(athletes[athlete_name].top3))
print(yate.include_footer({"Home": "/index.html",
"Select another athlete": "generate_list.py"}))


Best Regards

#4 Charly2001

Charly2001

    Active Member

  • Members
  • PipPip
  • 12 posts
  • Gender:Male
  • Location:Québec, Canada
  • Interests:Linux; Ubuntu 12.04

    anything Python

Posted 08 February 2014 - 06:29 PM

One more detail ! ! !

I noticed that in my installation of Python3.2
, only ROOT has permissions over the file server.py

Do I need to change that ? ? ?



#5 Charly2001

Charly2001

    Active Member

  • Members
  • PipPip
  • 12 posts
  • Gender:Male
  • Location:Québec, Canada
  • Interests:Linux; Ubuntu 12.04

    anything Python

Posted 15 February 2014 - 08:59 AM

I'm so HAPPY: found the answer

my python executable files are in the folder: /usr/bin That is where Idle3 installed them.

SO #! should point to the executable file: /usr/bin/python3

I added #! /usr/bin/python3 to the top of my scripts. Everything woks fine now

Cheers

#6 Charly2001

Charly2001

    Active Member

  • Members
  • PipPip
  • 12 posts
  • Gender:Male
  • Location:Québec, Canada
  • Interests:Linux; Ubuntu 12.04

    anything Python

Posted 15 February 2014 - 09:01 AM

I'm so HAPPY: found the answer

my python executable files are in the folder: /usr/bin That is where Idle3 installed them.

SO #! should point to that executable file: /usr/bin/python3

I added #! /usr/bin/python3 to the top of my scripts. Everything woks fine now

Cheers





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users