Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/471.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Python显示连接到服务器上的网页_Javascript_Python_Sendfile - Fatal编程技术网

Javascript Python显示连接到服务器上的网页

Javascript Python显示连接到服务器上的网页,javascript,python,sendfile,Javascript,Python,Sendfile,我使用JavaScript构建了一个服务器,当您连接到它时,它会显示一个网页。服务器在连接时使用发送了htm文件 app.get('/', function (req, res) { res.sendfile('index.htm'); }); Python中有类似的函数吗 import SimpleHTTPServer import SocketServer PORT = 8000 Handler = SimpleHTTPServer.SimpleHTTPRequestHandl

我使用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()