我正在python 3上编写一个简单的程序。这是我从计算机(本地)运行的代码0.html:
<html>
<title>CGI 101</title>
<body>
<H1>A first user interaction: forms</H1>
<hr>
<form method=POST action="https://www.pythonanywhere.com/user/TauGuard/files/home/TauGuard/newp.py">
{% csrf_token %}
<P><B>Enter your name:</B>
<P><input type=text name=user>
<P><input type=submit>
</form>
</body></html>
代码newp.py,位于&#34; https://www.pythonanywhere.com/user/TauGuard/files/home/TauGuard/newp.py&#34;:
import cgi
form = cgi.FieldStorage()
import ctypes
ctypes.windll.user32.MessageBoxA(0, ('Hello, %s.' % form['user'].value), "Your title", 1)
最后,我收到以下错误:
Forbidden (403)
CSRF verification failed. Request aborted.
You are seeing this message because this HTTPS site requires a 'Referer header' to be sent by your Web browser, but none was sent. This header is required for security reasons, to ensure that your browser is not being hijacked by third parties.
If you have configured your browser to disable 'Referer' headers, please re-enable them, at least for this site, or for HTTPS connections, or for 'same-origin' requests.
More information is available with DEBUG=True.
问题已结束。 我的问题是我想运行一个没有运行权限的文件。我只是不创建应用程序并在pythonanywhere.com上插入所需的逻辑。谢谢大家!