我試圖用Web.py創建一個網站,但它不讓我打開一個在端口80上創建套接字,但它適用於其他每個端口。爲什麼不通過Web.py讓我在端口80上運行服務器?
我有端口轉發和所有這些都不是問題。
python main.py 80
,但我這樣做時,我得到的錯誤:
http://0.0.0.0:80/
Traceback (most recent call last):
File "main.py", line 43, in <module>
app.run()
File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 311, in run
return wsgi.runwsgi(self.wsgifunc(*middleware))
File "/usr/local/lib/python2.7/dist-packages/web/wsgi.py", line 54, in runwsgi
return httpserver.runsimple(func, validip(listget(sys.argv, 1, '')))
File "/usr/local/lib/python2.7/dist-packages/web/httpserver.py", line 148, in runsimple
server.start()
File "/usr/local/lib/python2.7/dist-packages/web/wsgiserver/__init__.py", line 1753, in start
raise socket.error(msg)
socket.error: No socket could be created
到目前爲止我的代碼是:
import MySQLdb
import web
import hashlib as h
urls = (
'/', "index", "/register/?", "register", "/login/?", "login", "/thankyou/?", "thankyou"
)
app = web.application(urls, globals())
render = web.template.render("templates/")
db = web.database (dbn="mysql", user="root", pw="461408", db="realmd")
class index():
def GET(self):
return render.index()
class register():
def GET(self):
return render.register()
def POST(self):
i = web.input()
user = h.sha1(i.username).hexdigest()
pw = h.sha1(i.password).hexdigest()
n = db.insert("account", username=user, password=pw)
if __name__ == '__main__':
app.run()
能
有人幫助嗎?
你有偵聽端口80的另一個服務?像Apache一樣? 「 – Will
」......它適用於所有其他端口。「真? –
你有沒有試過端口81?也許是一個權限錯誤。在Linux上(至少),你需要是root用戶才能聽到這樣的低端口。 (我認爲)。 –