简体   繁体   English

Google App Engine返回“错误:服务器错误”

[英]Google App Engine returns 'Error: Server Error'

My app works locally and runs smoothly at localhost:8080. 我的应用程序在本地运行,并在localhost:8080上流畅运行。 It seems there's an issue when the app is executed in the Google servers. 在Google服务器上执行该应用程序时似乎出现了问题。

I am pretty sure that I have some packages missing, I already added the cloudstorage and requests packages into my lib folder. 我很确定我缺少一些软件包,我已经添加了cloudstorage并将请求软件包添加到我的lib文件夹中。

I would just like to know which ones do I have to download and add to the lib folder, here's what I am using in my Python app: 我只想知道必须下载哪些文件并将其添加到lib文件夹,这就是我在Python应用程序中使用的内容:

import os, sys, requests, csv, urllib2, webapp2                                 
import xml.etree.ElementTree as ET                                              
from datetime import date, timedelta, datetime                                  
from google.appengine.api import app_identity                                   
import cloudstorage as gcs

EDIT: 编辑:

I think I'm wrong and the packages part has nothing to do with the Error. 我认为我错了,而包部分与错误无关。

I found in the Stack Trace Sample these few lines: 我在堆栈跟踪示例中发现了以下几行:

Body: "<?xml version='1.0' encoding='UTF-8'?>
<Error>
<Code>AccessDenied</Code>
<Message>Access denied.</Message>
<Details>
Caller does not have storage.objects.create access to bucket bucket.
</Details>
</Error>". Extra info: None.

I am actually writing in a csv file on Google Cloud Storage, here's my few lines of code that are probably important 我实际上是在Google Cloud Storage上的一个csv文件中编写的,这几行代码可能很重要

        currentFileName = "/bucket/" + self.domain + "_" + self.startDate +"_" \
+ self.endDate +'.csv'

with gcs.open(currentFileName, 'w') as csvfile:                         
            fieldnames = ['ID', 'URL', 'Comments', 'Em...

...
writer = csv.DictWriter(csvfile,fieldnames = fieldnames)            

Did I do a mistake at the file path in the Bucket? 我是否在存储桶中的文件路径上犯了一个错误? I'm a little confused on how to check if it's creating the file correctly also. 我对如何检查它是否也正确创建文件感到有些困惑。

EDIT 2: 编辑2:

Do I need to use this line of code somewhere? 我是否需要在某处使用这一行代码?

    bucket_name = os.environ.get('BUCKET_NAME', app_identity.get_default_gc\
s_bucket_name())  

The error was the bucket directory, getting the bucket name with 错误是存储桶目录,使用以下命令获取存储桶名称

bucket_name = os.environ.get('BUCKET_NAME', app_identity.get_default_gc\
s_bucket_name())  

Then modifying the currentFileName to the correct directory which is 然后将currentFileName修改为正确的目录

currentFileName = "/" + bucket_name + "/" + self.domain + "_" + self.startDate +"_" \
+ self.endDate +'.csv'

Fixed the 500 Error: Server Error 修复了500错误:服务器错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM