【问题标题】:Python script (webpy) emitting http 500 error upon trying to open an existing filePython 脚本 (webpy) 在尝试打开现有文件时发出 http 500 错误
【发布时间】:2015-05-18 22:05:55
【问题描述】:

所以我不太确定这里的问题...基本上,只要我使用我正在使用的实时 API 来获取数据,一切正常。但是,如果我尝试打开其中包含相同确切数据的现有文件(来自先前的 api 调用),我会收到内部服务器错误。这是导致问题的代码块:

    thisFile = os.path.join(__location__, '2014/' + npi + '_individual.json')

    # if the local cached copy exists, then load that, otherwise, connect to the API
    if os.path.isfile(thisFile):
        target2 = open(thisFile)
        content = json.loads(target2.read())
    else:
        req = urllib2.Request(url + '?database=nppes&npi=' + npi + '&apikey=' + apiKey)
        r = urllib2.urlopen(req)
        content = json.loads(r.read())

我相信我正在使用 webpy 或 web2py(我不确定它们是否是两个独立的东西)。在 Apache2.4 上通过 WSGI 执行脚本。

【问题讨论】:

    标签: python json file web.py


    【解决方案1】:

    这是无关紧要的事情。基本上,这是失败的,因为......所以在第一次调用时,它正在优化我从 API 返回的数据,然后将这些 REFINED 数据存储在 json 文件中。

    所以下次加载时,json文件存在,加载的时候,在提炼的过程中,有些东西已经被重命名了,所以剩下的脚本不知道怎么执行了。愚蠢的问题。

    【讨论】:

      猜你喜欢
      • 2023-01-05
      • 2018-08-22
      • 2020-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-06
      • 2011-10-06
      相关资源
      最近更新 更多