我在谷歌应用程序引擎中的Python代码有什么问题? [发送电子邮件]

发布于 2024-11-27 00:59:05 字数 613 浏览 1 评论 0原文

我想使用 URL 查询 var ['f'] ['t'] ['s'] ['c'] 发送电子邮件。 当我在 googl 应用程序引擎中启动代码时,我明白了

错误:服务器错误

服务器遇到错误,无法完成您的请求。 如果问题仍然存在,请报告您的问题并提及这一点 错误消息以及导致该错误的查询。

我的代码是

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 send an email by using the URL query var ['f'] ['t'] ['s'] ['c'].
By when i launch the code in googl app engine, i see

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花想c 2024-12-04 00:59:05

登录 appengine.google.com 的管理控制台,点击您的应用,然后点击“日志”。此页面显示所有请求的日志记录,这是记录异常的地方 - 出于安全和可用性原因,而不是返回给用户的页面。该页面上的异常日志应该告诉您做错了什么。

另外,你真的不应该使用 CGI - 很难做到正确(提示:你需要首先输出标头),并且你会浪费时间重新发明轮子来完成很多使用 CGI 更容易完成的事情。适当的框架。请改用 WSGI 框架,像这样

Log in to your admin console at appengine.google.com, click on your app, and click on 'logs'. 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. Use a WSGI framework instead, like this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文