我真的很喜欢如何使用SimpleHTTPServer在网络上轻松共享文件,但我希望有一个选项,如"下载整个目录".是否有一种简单(单线程)的方式来实现这一点?
谢谢
如果我这样做,python -m SimpleHTTPServer它将提供当前目录中的文件.
我的目录结构如下所示:
/protected/public
/protected/private
/test
Run Code Online (Sandbox Code Playgroud)
我想在我的/test目录中启动服务器,我希望它在/test目录中提供文件.但我希望从/protected/public目录中提取以'/ public'开头的所有服务器请求.
ega请求http://localhost:8000/public/index.html将服务于该文件/protected/public/index.html
内置服务器可以实现这一点,还是必须编写自定义服务器?
我在JDK 1.6 http服务器上创建了一个基于jersey 1.12的宁静服务外观.当我在eclipse中启动我的应用程序时,一切正常.我可以毫无困难地与外观进行通信,但是当我使用启动脚本通过控制台启动应用程序时,我在访问服务时遇到了IncompatibleClassChangeError.
我能够缩小问题的范围.问题在于发送响应.因为我可以正常地与服务通信(请求被处理)但我没有得到回复.你对此有什么线索吗?
启动脚本
#!/usr/bin/env bash
libpath=
for i in $(ls lib/*|grep ".jar"); do
libpath=$( echo "$i:$libpath");
done
java -cp "$(echo $libpath)build/jar/myjar.jar" org.....Startup
Run Code Online (Sandbox Code Playgroud)
将被抛出的异常
WARNUNG: Class org....facade.ServiceFacadeImpl is ignored as an instance is registered in the set of singletons
Call getMutationList: NP_005378
Exception in thread "pool-1-thread-1" java.lang.IncompatibleClassChangeError: Class javax.ws.rs.core.Response$Status does not implement the requested interface javax.ws.rs.core.Response$StatusType
Run Code Online (Sandbox Code Playgroud)
我的门面的一部分
@GET
@Path("/mutations/{id}/{from}/{size}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public MutationPosContainer getMutationList(@PathParam("id") String id,
@PathParam("from") Integer from, @PathParam("size") Integer size) {
...
if (posContainer …Run Code Online (Sandbox Code Playgroud) 我正在python -m SimpleHTTPServer用于一个小项目.文件index.html引用了一些视频.
<video><source src="big_buck_bunny_480p_stereo.ogg"></video>
此文件的大小为159 MB.当我尝试下载它时,SimpleHTTPServer会抛出一些错误消息而不是我的视频.
Marc-Laptop - - [23/Sep/2012 18:18:29] "GET /big_buck_bunny_480p_stereo.ogg HTTP
/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('192.168.4.38', 51152)
Traceback (most recent call last):
File "C:Program Files (x86)PythonlibSocketServer.py", line 284, in _handle
_request_noblock
self.process_request(request, client_address)
File "C:Program Files (x86)PythonlibSocketServer.py", line 310, in process
_request
self.finish_request(request, client_address)
File "C:Program Files (x86)PythonlibSocketServer.py", line 323, in finish_
request
self.RequestHandlerClass(request, client_address, self)
File "C:Program Files (x86)PythonlibSocketServer.py", line 640, in __init_
_
self.finish()
File …Run Code Online (Sandbox Code Playgroud) LSOpenURLsWithRole() failed with error -600 for the URL http://localhost:9000/.
这是我尝试SimpleHTTPServer在tmux会话中启动时遇到的错误.我是一名前端Web开发人员,而且我大部分时间都在使用a SimpleHTTPServer而不是Apache.问题是它在open命令错误,因为我习惯直接从终端打开文件和目录(open dirname/,或open .),当我使用它时,tmux它给我同样的错误.我想提一下,我在Macbook Air上运行OSX 10.9 Mavericks.
这是我在终端中用来启动服务器的函数的代码:
# Start an HTTP server from a directory, optionally specifying the port
function server() {
local port="${1:-8000}"
open "http://localhost:${port}/"
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
python -c …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 PyQt 创建一个简单的桌面应用程序,该应用程序在单击启动服务器按钮时运行 SimpleHTTPServer。我尝试过使用线程(Python 线程和 Qthread),并且明白这是不可能的,因为它会遇到 GIL 问题。这是代码
def btn_startserver_clicked(self):
server_thread=threading.Thread(target=start_server())
server_thread.start()
def start_server():
#to get server's IP
host=([(s.connect(('8.8.8.8', 80)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1])
start=8000
end=56999
PORT = random.randint(start,end)
print host,":",PORT
httpd=ThreadedServer(("",PORT), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.handle_request()`
Run Code Online (Sandbox Code Playgroud)
我尝试创建另一个进程,但发生了同样的事情。另外,如果我创建另一个进程,每次处理请求时都会弹出一个新窗口。
def btn_startserver_clicked(self):
if __name__=='__main__':
server_process=Process(target=start_server())
server_process.start()
Run Code Online (Sandbox Code Playgroud)
有没有办法解决?我觉得使用多处理是正确的方法,但我对此很陌生,无法弄清楚为什么它仍然冻结。
谢谢
我正在编写一个包含以下内容的简单集成测试:
I know #2 works and I have no problem with this.
但是,#1仅适用于前几个浏览器,然后挂起,导致随后的浏览器测试失败。我真的不明白为什么。
在我的代码中,这是我正在做的事情:
class Test:
def setup_class(cls):
ready_signal = threading.Event()
cls.port = 9000
cls.docroot = /tmp
cls.http_wrapper = SimpleHTTPWrap(port=cls.port, docroot=cls.docroot, ready_signal)
background_thread = threading.Thread(target=http_wrapper.start)
background_thread.daemon = True
background_thread.start()
ready_signal.wait(10) # Wait for thread to be ready (or proceed after timeout)
def test(self):
ip = get_my_ip_address()
self.browser = webdriver.Remote(_some_parameters_go_here)
self.browser.get('http://' + ip + ":" + cls.port + cls.docroot + '/test.html')
# This hangs after similar tests have already …Run Code Online (Sandbox Code Playgroud) 我想提供一个强制门户http.server页面,该页面会提示用户在开始使用运行最新版本 Raspbian 的 Raspberry Pi 上的无线网络(通过 WiFi)浏览网页之前同意某些条款。
我已经http.server(Python3 附带)启动并portal.html在 Pi 上本地运行了一个网页。这是我希望用户在连接到我的 Pi 时被重定向到的页面。假设该页面的本地 IP 是192.168.1.5:80/portal.html
我的想法是,当他们连接并接受条款和条件时,我会以某种方式允许他们连接。
我该怎么办呢?
networking simplehttpserver python-3.x captivenetwork captiveportal
我正在查看一个 Three.js 示例,当我import在 javascript 模块中使用时,出现错误:\nLoading module from \xe2\x80\x9chttp://localhost:8000/build/three.module.js\xe2\x80\x9d was blocked because of a disallowed MIME type (\xe2\x80\x9c\xe2\x80\x9d).
当我使用脚本标记传统导入时,我不会收到此错误。这是我的代码:
\n注释掉的线将渲染一个旋转的立方体
\n<!DOCTYPE html>\n<html>\n <head>\n <title>My first three.js app</title>\n <style>\n body { margin: 0; }\n </style>\n </head>\n <body>\n <script type="module">\n\n import * as THREE from '/build/three.module.js';\n // const scene = new THREE.Scene();\n // const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );\n\n // const renderer = new THREE.WebGLRenderer();\n // renderer.setSize( window.innerWidth, window.innerHeight );\n // …Run Code Online (Sandbox Code Playgroud) simplehttpserver ×10
python ×8
http ×1
java ×1
javascript ×1
jersey ×1
macos ×1
mime-types ×1
networking ×1
pyqt ×1
python-3.x ×1
rest ×1
socketserver ×1
tcpserver ×1
terminal ×1
tmux ×1