10
我想發佈到我的龍捲風Web服務器,但不斷得到405錯誤。不知道發生了什麼問題。我對python相當陌生,但我一直在尋找這個約一個月,最後決定放棄它。發佈到龍捲風服務器
龍捲風Web服務器:
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
import os
import string
from time import sleep
from datetime import datetime
import hashlib
import json
from tornado.options import define, options
define("port", default=8001, help="run on the given port", type=int)
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
class LoginHandler(tornado.web.RequestHandler):
def get(self):
email_address = self.get_argument('email')
password = self.get_argument('password')
if email_address == '':
login_response = "{'error': true, 'msg': 'Please enter your email address.'}"
elif password == '':
login_response = "{'error': true, 'msg': 'Please enter your password.'}"
else:
login_response = "{'error': true, 'msg': 'Thank You.'}"
self.response.headers['Content-Type'] = "application/json"
self.response.out.write(json.dumps(login_response))
def main():
tornado.options.parse_command_line()
application = tornado.web.Application([
(r"/", MainHandler),
(r"/login", LoginHandler),
])
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
if __name__ == "__main__":
main()
HTML:
<form id="login_form" action="http://www.mydomain.com/server/login" method="post">
<label class="grey" for="log">Email Address</label><br />
<input type="text" name="email" style="width:99%" id="email"><br>
<label class="grey" for="pwd">Password</label><br />
<input type="password" name="password" style="width:99%" id="password"><br />
<label>
<input name="remember" type="checkbox" checked="checked" value="1" /> Remember me</label><br /><br />
<input type="submit" id="loginbtn" name="login" value="LOGIN" class="button"><br />
<a href="forgotpassword.php">Forgot your password?</a>
</form>
當我改變它的帖子我比拿到500:內部服務器錯誤 – Bobby
@Bobby,哎呀呀。我沒有真正測試過它。固定。 – daharon
非常感謝。我已經知道了它的錯誤,但無法弄清楚爲什麼如果一個參數沒有進入它不工作,完全忘了'''''get_argument' – Bobby