2012-11-05 5 views
1

이 작업은 명령 줄을 통해 작동하지만 웹 브라우저를 통해 작동하지 않는 이유는 무엇입니까? (파이썬에서 두 파일 만 2 일로드) 나는 그것이 매개 변수 "User_Name을"에 전달 파일 "Pass_Word"을 사용하여 호출이 기능은 웹 브라우저가 아닌 명령 줄을 통해 작동합니까?

import cgi 
import cgitb; cgitb.enable() 
import BaseHTTPServer 
from SimpleHTTPServer import SimpleHTTPRequestHandler 
# get the info from the html form 
form = cgi.FieldStorage() 
#set up the html stuff 
reshtml = """Content-Type: text/html\n 
<html> 
<head><title>login</title></head> 
<body> 
""" 

print reshtml 

User_Name = form.getvalue('User_Name') 
password = form.getvalue('Pass_Word') 
log="info: " 
if User_Name == 'NAME' and password == 'passcode': 
    log=log+"login passed " 
else: 
    log=log+"login failed " 
print log 
print '</body>' 
print '</html>' 

:

#!/Python27/python 
print "Content-type: text/html" 
print 
print """ 
<html><head> 
<title>log in</title> 
</head><body> 
""" 
import sha, time, Cookie, os, fileinput, cgi, cgitb 
import sys 
import BaseHTTPServer 
from SimpleHTTPServer import SimpleHTTPRequestHandler 
log = "info: " 
cookie = Cookie.SimpleCookie() 
string_cookie = os.environ.get('HTTP_COOKIE') 
string_cookie = str(string_cookie) 
infoform = """ 
    <link rel="stylesheet" type="text/css" href="styles/home.css" media="screen" /> 
    <div id="top" style=" height:50px;width:100%;position:absolute;left:0px;top:0px;" > 
    <form action="router.py" method="post" target="_self"> 
    <div id="form" style="position:absolute;left:15px;top:20px;" > 
    <input type="text" name="User_Name" value="User Name"> 
    <input type="password" name="Pass_Word" value="Password"> 
    <input type="hidden" name="status_url"> 
    <input type="submit" value="Log in"> 
    </div> 
    </form> 
    <div ID"home"></div> 
    </div> 

    <div id="GBbody" style="position:absolute;left:1px;top:55px;height:100%;width:100%;" > 
    <p id="disply"> 
    <center><h2> 
    Hi, and welcome! 
    </h2></center> 
    <h4>  
    Did you know: just the movie player and code that goes with it takes<br> 
    474 lines of code so-far, and may not work many web browsers (for the time being), however <br> 
    Google chrome is fully compatible at this point. 
    </h4> 
    </p> 
    </div> 
    """ 
loginas = """ 
<form action="home.py" method="post" target="_self"> 
<input type="submit" value="Continue last session" style="position:absolute;right:15px;top:20px;"> 
</form> 
""" 
if "sess" in string_cookie: 
    infoform = infoform.replace('<div ID"home"></div>',loginas) 
    print infoform 
else: 
    print infoform 

print "</body></html>" 

을하지만, 그것은 출력한다 내부 서버 오류 페이지, 도움? 게시 스크립트 방금 python을 재설치했습니다. 2.7.3

답변

0

Flask를 사용하여 디버깅을 지원할뿐 아니라 Flask를 사용하지 않으려는 경우 웹 서비스를 만드는 데 필요한 모든 도구를 사용할 수 있습니다. 귀하의 서버 (아파치 또는 nginx) 로그를 봐

관련 문제