Jump to content

J..

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by J..

  1. Okay, sorry to bother you again, but urllib2.urlopen doesn't seem to be working in Django. If I put the following script in cgi-bin:

    #!/usr/bin/python
    print "Content-type:text/html\n"
    from urllib2 import urlopen, URLError
    out = ""
    try:
        urlopen("http://google.com")
    except URLError, e:
        print "<p>"+str(e.reason)+"</p>"
    print "<p>done</p>"

    The output is '<p>done</p>'. But if I use this in Django (views.py):

    from django.shortcuts import HttpResponse
    from urllib2 import urlopen, URLError
    
    def sample (request):
        out = ""
        try:
            urlopen("http://google.com")
        except URLError, e:
            out += "<p>"+str(e.reason)+"</p>"
        out += "<p>done</p>"
        return HttpResponse(out)

    The output is '<p>unable to select on socket</p><p>done</p>'.

     

    Is there any reason this might be happening? These are located here and here respectively

  2. I've followed the instructions here, but I just see the dispatch.wsgi file's source code, even though its permissions are set to 755. The project is just something simple to see if I could get it to work, and it runs fine locally. Have I done something wrong?

×
×
  • Create New...