My problem with Dynamic Web Page at PythonAnywhere

Back to Problem Solutions forum

Aghiad     2015-02-01 20:04:13
User avatar

Hi i am trying to solve Dynamic Web Page problem but when i load the web page on my browser it prints my code instead of giving me the solution can u please help me this is my solution:

#!/usr/bin/env python

import random

print "Content-Type: text/plain"
print

def randomize():
    num=random.randint(10000,99999999)
    while num%1250!=0:
        num=random.randint(10000,99999999)
    return num
print "Random value is " + str(randomize());

thanks for helping

Rodion (admin)     2015-02-02 05:47:54
User avatar

Hi! Could you please tell, where you store your page - i.e. where from you load it with your browser?

Aghiad     2015-02-02 13:32:53
User avatar

http://mazein1978.pythonanywhere.com/codeabbey/solution.py

Rodion (admin)     2015-02-02 14:03:20
User avatar

Ah, I see.

I'm afraid this could not work. PythonAnywhere requires you to use more modern (and bit more complicated) WSGI interface instead of old CGI. However if you want you can read these instructions and I believe you'll be able to make necessary changes in few minutes.

If you prefer to use CGI-style code, you need to use simple hosting (like CgiWebHost).

Aghiad     2015-02-02 21:04:08
User avatar

Have just solved it . Thanks for the supporting and the instructions were more than helpful :) .

Please login and solve 5 problems to be able to post at forum