O'Reilly Forums: Chapter 8 As_Dict Problem - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Chapter 8 As_Dict Problem

#1 User is offline   weiyan linn 

  • New Member
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 27-January 13

Posted 27 January 2013 - 01:12 PM

I almost finished the chapter 8 program,
but I stack at the as_dict .

if I didn't us as_dict , I get the problem as same as the book say on page 284:

192.168.1.100 - - [27/Jan/2013 15:43:16] command: C:\Python33\python.exe -u C:\python\webapp\cgi-bin\generate_data.py ""

192.168.1.100 - - [27/Jan/2013 15:43:16] b'["2-34", "3:21", "2.34", "2.45", "3.01", "2:01", "2:01", "3:10", "2-22", "2-0
1", "2.01", "2:16"]\r\n'


after I use as_dict and I also applied in the generate_data.py
but :
1. I didn't find anything I should change in the coachapp.py
I find the code of coachapp.py on page287 is just as same as page282

2.And I have another problem:

192.168.1.100 - - [27/Jan/2013 15:48:11] command: C:\Python33\python.exe -u C:\python\webapp\cgi-bin\generate_data.py ""

192.168.1.100 - - [27/Jan/2013 15:48:12] b'{"DOB": "2002-3-14", "Name": "James Lee", "Top3": ["2.01", "2.16", "2.22"]}\r
\n'
192.168.1.100 - - [27/Jan/2013 15:48:12] CGI script exited OK


I thought it seem like that I have been succeed put out the the data from generate_data.py as dictionary
but It can not be get by the android phone?

What did I do wrong? :(

This post has been edited by weiyan linn: 27 January 2013 - 01:12 PM

0

#2 User is offline   paulbarry 

  • Advanced Member
  • PipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 306
  • Joined: 20-August 09

Posted 28 January 2013 - 02:53 AM

A few suggestions:

1. Check out the errata for the book (here: http://oreilly.com/c...n=0636920003434) in case this is an issue that has already been reported.

2. Please upload your code as part of your problem description (being sure to set the Style to Code so that the correct tags are used and the formatting is maintained). Without being able to see your code, it's hard to work out what is going on.

Thanks.

--Paul.
0

#3 User is offline   weiyan linn 

  • New Member
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 27-January 13

Posted 28 January 2013 - 11:02 AM

View Postpaulbarry, on 28 January 2013 - 02:53 AM, said:

A few suggestions:

1. Check out the errata for the book (here: http://oreilly.com/c...n=0636920003434) in case this is an issue that has already been reported.

2. Please upload your code as part of your problem description (being sure to set the Style to Code so that the correct tags are used and the formatting is maintained). Without being able to see your code, it's hard to work out what is going on.

Thanks.

--Paul.


Thanks your help guys!

the " file=sys.stderr" in the print(json.dumps(athleteable.as_dict),file=sys.stderr) on page284
is used to debugging...

we should delete it from generate_data.py

if you want to actually run your application.

-- weiyan linn
0

#4 User is offline   weiyan linn 

  • New Member
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 27-January 13

Posted 28 January 2013 - 12:09 PM

View Postpaulbarry, on 28 January 2013 - 02:53 AM, said:

A few suggestions:

1. Check out the errata for the book (here: http://oreilly.com/c...n=0636920003434) in case this is an issue that has already been reported.

2. Please upload your code as part of your problem description (being sure to set the Style to Code so that the correct tags are used and the formatting is maintained). Without being able to see your code, it's hard to work out what is going on.

Thanks.

--Paul.



New problem.....

The cocahapp.py is ok on the simulator

and then, I put it into my android phone

running in the sl4a

but after it show " welcom to..."

it stucked ... I find it shows "127.0.0.1 :37682 " on coachapp.py on sl4a,

does it means sl4a is not allow access to the network?
0

#5 User is offline   paulbarry 

  • Advanced Member
  • PipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 306
  • Joined: 20-August 09

Posted 29 January 2013 - 01:13 AM

Please refer to page 275. Do you see the IP address in the code that is underlined? You need to change this to the IP address of the PC that is running your web server. Note that using 127.0.0.1 tells your device to look for the web server on itself, as 127.0.0.1 is an alias for "this computer". This works when running the emulator, as the emulator and the web server are on the *same* PC, but once you run from a phone, you need to tell the code the real IP address of your computer.

Hope this helps.

--Paul.
0

#6 User is offline   weiyan linn 

  • New Member
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 27-January 13

Posted 29 January 2013 - 11:34 AM

View Postpaulbarry, on 29 January 2013 - 01:13 AM, said:

Please refer to page 275. Do you see the IP address in the code that is underlined? You need to change this to the IP address of the PC that is running your web server. Note that using 127.0.0.1 tells your device to look for the web server on itself, as 127.0.0.1 is an alias for "this computer". This works when running the emulator, as the emulator and the web server are on the *same* PC, but once you run from a phone, you need to tell the code the real IP address of your computer.

Hope this helps.

--Paul.


But, I have already made it my computer address 192.168.1.101

but the problem is still happened- -.
0

#7 User is offline   weiyan linn 

  • New Member
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 27-January 13

Posted 29 January 2013 - 02:41 PM

problem solved!!!!!!
I forget to transfer it after I changed ip address.....................

Thank you so much!!!!
I am now so exciting!!! I finished my first android app!!!! :rolleyes: :rolleyes: :rolleyes: :D
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users