我使用 JavaScript 构建了一个服务器,当您连接到它时,它会显示一个网页。服务器在连接时发送 htm 文件,使用
app.get('/', function (req, res) {
res.sendfile('index.htm');
});
Python中有类似的函数吗?
最佳答案
import SimpleHTTPServer
import SocketServer
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()
关于javascript - Python 在连接到服务器时显示网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24744125/