简体   繁体   English

我在Google App Engine中的python代码怎么了? [发送电子邮件]

[英]what's wrong with my python code in google app engine? [send an email]

I want to send an email by using the URL query var ['f'] ['t'] ['s'] ['c']. 我想使用URL查询var ['f'] ['t'] ['s'] ['c']发送电子邮件。 By when i launch the code in googl app engine, i see 当我在Googl应用引擎中启动代码时,我看到了

Error: Server Error 错误:服务器错误

The server encountered an error and could not complete your request. 服务器遇到错误,无法完成您的请求。 If the problem persists, please report your problem and mention this error message and the query that caused it. 如果问题仍然存在,请报告您的问题并提及此错误消息以及引起该问题的查询。

my code is 我的代码是

import cgi
from google.appengine.api import mail

form = cgi.FieldStorage()

sendfrom = form.getvalue("f")
reciver = form.getvalue("t")
title = form.getvalue("s")
content = form.getvalue("c")

print sendfrom
print reciver
print title
print content


mail.send_mail(
    sender = sendfrom,
    to = reciver,
    subject = title,
    body = content
)

i want to know what's wrong with my code? 我想知道我的代码有什么问题吗?

Log in to your admin console at appengine.google.com, click on your app, and click on 'logs'. 通过appengine.google.com登录到您的管理控制台,单击您的应用程序,然后单击“日志”。 This page shows log records for all your requests, and this is where exceptions are logged - not to the page returned to the user, for security and usability reasons. 此页面显示所有请求的日志记录,并且出于安全和可用性的原因,这是记录异常的位置-不在返回给用户的页面上。 The exception log on that page ought to tell you what you're doing wrong. 该页面上的异常日志应该告诉您您在做什么错。

Also, you really shouldn't be using CGI - it's difficult to get right (hint: you need to output headers first), and you'll waste your time reinventing the wheel for a lot of things that are much easier to do with a proper framework. 另外,您实际上不应该使用CGI-很难正确使用(提示:您需要首先输出标头),并且您会浪费大量时间来重新设计轮子,这很多事情可以通过使用CGI来轻松完成。适当的框架。 Use a WSGI framework instead, like this . 改用WSGI框架, 像这样

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

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