手机索引html打不开,无法重定向到索引.html登录后的页面

我的客户端应用程序首先从登录.html页面,然后当按下“登录”按钮时,一个函数“display()”运行,从输入字段存储ID和密码并将其发送到服务器。服务器批准登录ID和密码并尝试发送索引.html第页。但我无法发送索引.html第页。可能是我的HTML代码或服务器端遗漏了什么。你知道吗

我的HTML(bootstrap)代码是

Sign In link

JavaScript“Display()”函数:

function Display(){

var ID = document.getElementById("user_id").value;

var passwrd = document.getElementById("password_id").value;

var login = "/login:" + ID + "-" + passwrd + "--" ;

var http = new XMLHttpRequest();

http.open("GET", login, true);

http.onreadystatechange = function() { if(http.readyState == 4 && http.status == 200) {

var data = http.responseText;

if (data=="0"){

document.getElementById("info_id").innerHTML = "wrong password";

}

else if (data=="1"){

document.getElementById("info_id").innerHTML = "logging in as Admin";

page();

}

}

}

http.send(null);

}

function page(){

var request = new XMLHttpRequest();

request.onreadystatechange = function() {

if (request.readyState === 4) {

if (request.status === 200) {

//document.body.className = 'ok';

//console.log(request.responseText);

} else {

//document.body.className = 'error';

}

}

};

request.open("GET", "index.html" , true);

request.send(null);

}

基于Python的httpserver代码是:class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):

def do_HEAD(s):

s.send_response(200)

s.send_header("Content-type", "text/html")

s.end_headers()

def do_GET(s):

HTTP_request=s.requestline

index_1=HTTP_request.index("GET /")

index_2=HTTP_request.index(" HTTP/1.1")

file_name=HTTP_request[index_1+5:index_2]

print 'HTTP_request:',HTTP_request

if HTTP_request.find('login')>-1:

print 'got', file_name # file name is formatted as "login:anum-1234--"

ID = file_name[6:file_name.find('-')]

password = file_name[file_name.find('-')+1:file_name.find('--')]

if ID == "anum" and password == "1234":

admin = 1

print 'admin ENTERED' #

file1=open('index.html','r')

file_read=file1.read()

s.send_response(301)

s.send_header('Location','http://index.html') #

#s.send_header('Location',file_read) ##

s.end_headers()

else:

admin = 0

s.wfile.write("0")

任何形式的帮助都将不胜感激,提前感谢:)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值