什么是Python 3相当于python -m SimpleHTTPServer?
我从这个链接克隆了一个关于Web浏览器上实时图像处理的项目:然后我无法允许我的浏览器访问我的相机.我收到了这个javascript警报:
呃哦,网络摄像头没有启动.你有网络摄像头吗?你给了它许可吗?刷新再试一次.并且不显示允许按钮,就像我访问他的网站一样.
我目前正致力于服务工作者在浏览器中处理推送通知.目前我有这个"SW注册失败错误".有人可以帮忙解决这个问题吗?检查client1.html并service-worker.js归档如下:
错误:
SW注册失败,出现错误SecurityError:无法注册ServiceWorker:不支持当前源的URL协议('null').
服务worker.js
console.log('Started', self);
self.addEventListener('install', function(event) {
self.skipWaiting();
console.log('Installed', event);
});
self.addEventListener('activate', function(event) {
console.log('Activated', event);
});
self.addEventListener('push', function(event) {
console.log('Push message received', event);
});
Run Code Online (Sandbox Code Playgroud)
client1.html
<!doctype html>
<html>
<head>
<title>Client 1</title>
</head>
<body>
<script>
if('serviceWorker' in navigator){
// Register service worker
navigator.serviceWorker.register('service-worker.js').then(function(reg){
console.log("SW registration succeeded. Scope is "+reg.scope);
}).catch(function(err){
console.error("SW registration failed with error "+err);
});
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我知道D3.js支持使用XHR和JSONP 请求加载数据文件.
但是在我的情况下,我将通过从文件系统双击它们来运行.html文件,这将file://.../foo.html在浏览器上运行它.
是否可以在计算机的同一目录中加载数据文件(csv或json),foo.html而不是在浏览器上运行(但不运行http://但是file://)?
当我运行python -m SimpleHTTPServer 8000或python -m CGIHTTPServer 8000在 cmd 中时,出现此错误:
没有名为 SimpleHTTPServer 的模块
或者
没有名为 CGIHTTPServer 的模块
有谁知道为什么会发生这种情况或测试 python cgi-scripts 的另一种方法?
javascript ×2
python ×2
python-3.x ×2
browser ×1
camera ×1
cgi ×1
d3.js ×1
httpserver ×1
web-push ×1