WebFaction
Community site: login faq

My code runs fine locally but I get a 500 error using the webfaction server. The problem seems to come from the line

js = json.load(data)

in the search method. Is there something in the cherrypy config that I'm missing? Any thoughts?

#!/usr/local/bin/python3.2
import cherrypy
import json
import numpy as np
from urllib.request import urlopen

class Root(object):
    @cherrypy.expose
    def index(self):

            a_query = Query()
            text = a_query.search()

            return '''<html>
            Welcome to Spoti.py! %s
            </html>''' %text

class Query():

    def __init__(self):
        self.qstring = '''if i can't'''

    def space_to_plus(self):
        self.qstring = self.qstring.replace(' ', '+')

    def search(self):
        self.space_to_plus()
        url = 'http://ws.spotify.com/search/1/track.json?q=' + self.qstring
        data = urlopen(url)
        js = json.load(data)
        return self.qstring

cherrypy.config.update({
    'environment': 'production',
    'log.screen': False,
    'server.socket_host': '127.0.0.1',
    'server.socket_port': 15083,
})

cherrypy.config.update({'tools.sessions.on': True})

cherrypy.quickstart(Root())

asked 14 Sep '13, 05:19

joestox
31713
accept rate: 0%

edited 14 Sep '13, 05:22

If you check your application logs it should show you what the error is about. You can find instructions for checking application / website logs here: http://docs.webfaction.com/software/general.html#accessing-logs

(14 Sep '13, 21:24) waynek
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×337
×32
×9
×3

question asked: 14 Sep '13, 05:19

question was seen: 3,540 times

last updated: 14 Sep '13, 21:24

                              
WEBFACTION
REACH US
SUPPORT
LEGAL
© COPYRIGHT 2003-2021 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM