最小,独立,可分发,跨平台的Web服务器 [英] Minimal, Standalone, Distributable, cross platform web server

查看:168
本文介绍了最小,独立,可分发,跨平台的Web服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在编写相当数量的小型wsgi应用程序,我希望找到一个可以分发的Web服务器,预先配置为运行特定的应用程序。我知道有些东西像twisted和cherrypy可以提供wsgi应用程序,但它们似乎缺少我的一个关键功能,这是使用http范围标题伪流大文件的能力。是否有可在BSD或类似许可下使用的Web服务器,可以在任何主要平台上作为独立可执行文件进行分发,这些平台既可以代理到wsgi服务器(如cherrypy等),也可以使用http服务大文件范围标题?

I've been writing a fair number of smaller wsgi apps lately and am looking to find a web server that can be distributed, preconfigured to run the specific app. I know there are things like twisted and cherrypy which can serve up wsgi apps, but they seem to be missing a key piece of functionality for me, which is the ability to "pseudostream" large files using the http range header. Is there a web server available under a BSD or similar license which can be distributed as a standalone executable on any of the major platforms which is capable of both proxying to a a wsgi server (like cherrypy or the like) AND serving large files using the http range header?

推荐答案

Lighttpd拥有BSD许可证,因此您可以根据需要捆绑它。

Lighttpd has a BSD license, so you should be able to bundle it if you wanted.

你说它适用于小型应用程序,所以我想这意味着小型本地单用户Web界面由小型http服务器提供服务?如果是这种情况,那么任何python实现都应该有效。只需使用像py2exe这样的东西打包它(事实上,不久前就有一个关于打包python程序的问题)。

You say its for small apps, so I guess that means, small, local, single user web interfaces being served by a small http server? If thats is the case, then any python implementation should work. Just use something like py2exe to package it (in fact, there was a question relating to packaging python programs here on SO not too long ago).

更新,重新:范围header:
默认的python http服务器可能不支持你想要的范围标题,但它很容易编写你自己的处理程序,或者一个小的wsgi应用程序来做逻辑,特别是如果你所做的只是流式传输文件。行数不会太多:

Update, re: range header: The default python http server may not support the range header you want, but its pretty easy to write your own handler, or a small wsgi app to do the logic, especially if all you're doing is streaming a file. It wouldn't be too many lines:

def stream_file(environ, start_response):
  fp = open(base_dir + environ["PATH_INFO"])
  fp.seek(environ["HTTP_CONTENT_RANGE"]) # just an example
  start_response("200 OK", (('Content-Type', "file/type")))
  return fp

这篇关于最小,独立,可分发,跨平台的Web服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆