标签: httpserver

提供用Lisp编写的Web应用程序的首选方法是什么?

我一直在为Nginx(我首选的网络服务器)研究模块来提供Lisp webapp,但是我找不到任何东西.

是否有Nginx的模块,或者有更好的方式来提供Lisp webapps?如果是这样,他们是什么?

lisp web-applications nginx httpserver

2
推荐指数
1
解决办法
710
查看次数

如何从BaseHTTPRequestHandler访问HTTPServer的成员?

我正在整理一个涉及GUI,HTTP和TCP服务器的小应用程序.GUI控制从HTTP和TCP服务器返回到客户端的响应.我使用HTTPServer和SocketServer.TCPServer类作为服务器,具有BaseHTTPRequestHandler和StreamRequestHandler的子类.但是让我们首先关注事物的HTTP方面.

当HTTPServer收到请求时,它应该检查GUI的状态,并做出适当的响应.我已经将一个成员变量添加到指向GUI的HTTPServer,但是无法找到从BaseHTTPRequestHandler子类访问该字段的好方法.如何才能做到这一点?

下面是我目前的代码,虽然Python抛出异常,MyHTTPHandler instance has no attribute 'server':

class MyHTTPHandler(BaseHTTPRequestHandler):
    def __init__(self, request, client_address, server):
        BaseHTTPRequestHandler.__init__(self, request, client_address, server)
        self._server = server

    def do_GET(self):
        self._server.get_interface().do_something()
        [...]
Run Code Online (Sandbox Code Playgroud)

python basehttpserver httpserver

2
推荐指数
1
解决办法
1826
查看次数

python http web服务器

我在本地网络上为我的家人创建了一个简单的http服务器,当我添加一个html文件和png图片并试图查看HTML文件时,我的图像无法加载.
它说:
"图像'的http:// ...:255/header.png’无法显示,因为它包含的错误."
这是我的一些代码

        elif self.path.endswith(".bm"):   #our dynamic content
            self.send_response(200)
            self.send_header('Content-type',    'text/html')
            self.end_headers()
            f= open(curdir + sep + self.path)
            ren = self.render(f.read())
            self.wfile.write(ren)
            return
        elif self.path.endswith('.png'):
            print "IMAGE WANTED!"
            self.send_response(200)
            self.send_header('Content-type',    'image/png')
            self.end_headers()
            f = open(curdir + sep + self.path)
            self.wfile.write(f.read())
            return
        elif self.path.endswith('.jpg'):
            print "IMAGE WANTED!"
            self.send_response(200)
            self.send_header('Content-type',    'image/jpeg')
            self.end_headers()
            f= open(curdir + sep + self.path)
            print f.read()
            self.wfile.write(f.read())
            return
        elif self.path.endswith(".esp"):
            self.send_response(200)
            self.send_header('Content-type',    'text/plain')
            self.end_headers()
            self.wfile.write("This Format Is Not Supported Any More, Upgrade To …
Run Code Online (Sandbox Code Playgroud)

python http httpserver basehttprequesthandler

2
推荐指数
1
解决办法
3191
查看次数

如何在nodejs中返回格式化的JSON对象

我正在制作以下nodejs服务器

var http = require('http');
var port = 1337;
http.createServer(function(req, res) {
    var statusList = {
      "hasErrors": false,
      "list" : [
        { "id": "spec1",
          "name": "retrieve blog info"
        },
        { "id": "spec2",
          "name": "Retrieve a Blog Avatar"
        },
        { "id": "spec3",
          "name": "Retrieve Blog's Likes"
        },
        { "id": "spec4",
          "name": "Retrieve a Blog's Followers"
        }
      ],
      "totalRecords": 4
    };
    console.log(req);
    console.log(statusList);
    res.writeHead(200, { 'Content-Type': 'application/json', "Access-Control-Allow-Origin":"*" });
    res.write(JSON.stringify(statusList));
    res.end();
}).listen(port);
Run Code Online (Sandbox Code Playgroud)

但这只是statusList在浏览器页面上显示没有任何格式(只是一个没有任何空格或输入的字符串).我希望json在浏览器中看到结构化格式,以便清晰可见.

我也不想在浏览器上安装任何类型的插件.

另请注意,如果我删除JSON.stringify()并只是返回对象statusList …

javascript json httpserver node.js

2
推荐指数
1
解决办法
8936
查看次数

我可以从http.ResponseWriter获取io.Writer吗?

我想json.Encoder用来写一个http.ResponseWriter.

我不知道,我在哪里得到http.ResponseWriter自己io.Writer

(io.Writer作为参数需要json.NewEncoder)

有任何想法吗?

io json go httpserver

2
推荐指数
1
解决办法
1301
查看次数

如何在HttpHandler(Julia语言)中获取客户端IP地址?

我需要在常规的HttpHandler中获取客户端的IP地址,如下所示:

http = HttpHandler() do req::Request, res::Response
    Response( ismatch(r"^/hello/",req.resource) ? string("Hello ", split(req.resource,'/')[3], "!") : 404 )
end
Run Code Online (Sandbox Code Playgroud)

既不包含req也不http.sock包含此信息.

http httpserver julia

2
推荐指数
1
解决办法
790
查看次数

NanoHTTPD如何将上传的文件保存到sdcard文件夹

如何将上传的文件保存到sdcard文件夹,目前它存储到/ data/data/cache文件夹,文件名为"NanoHTTPD-some random number".

我无法将其复制到SD卡中的任何文件夹位置.

我想将文件保存到sdcard中预先提到的文件夹位置,其名称与从我的html页面上传的原始文件名相同.

我尝试了所有类型的代码.但文件复制始终失败.1)无法获得临时文件的正确位置.2)没有获得表单发布的原始文件名

这是我的实施.

请帮助我被卡住了.

    public class HttpMultimediaServer extends NanoHTTPD {
    private static final String TAG = "HttpMultimediaServer";
    private FileInputStream fileInputStream;

    public HttpMultimediaServer() {
        super(12345);
        this.setTempFileManagerFactory(new ExampleManagerFactory());
    }

    @Override 
    public Response serve(IHTTPSession session) {
        Method method = session.getMethod();
        String uri = session.getUri();

        Log.e("handle", "url>>" + uri);

        if (uri.contains(filesOnly)) {
            isfilesOnly = true;
            uri = "/";
        } else
            isfilesOnly = false;

        uri = uri.replace("%20", " ");

        try {
            uri=new String (uri.getBytes ("iso-8859-1"), "UTF-8");
        } catch (UnsupportedEncodingException e2) …
Run Code Online (Sandbox Code Playgroud)

android httpserver nanohttpd

2
推荐指数
1
解决办法
3818
查看次数

同时使用http-server和node express服务器

我已经看到了节点快速服务器的以下设置:

server.js

import { Server } from 'http'; 
import Express from 'express'; 

const app = new Express(); 
const server = new Server(app);
Run Code Online (Sandbox Code Playgroud)

既然可以直接运行express,那么将express服务器作为http服务器的参数返回有什么好处呢?

httpserver node.js express server

2
推荐指数
1
解决办法
314
查看次数

npm http服务器不断缓存我的App.js

我正在学习AngularJS。我正在使用npm http-server在本地运行项目。

问题是,每当我对App.js进行更改时,更改都不会反映在网站上。我尝试刷新页面,但不会更新对JS的更改。我还尝试了http-server -o -c-1,但它仍然没有刷新缓存。

进行App.js更新的唯一方法是清除浏览器缓存。我应该怎么做?

javascript caching httpserver npm angularjs

2
推荐指数
2
解决办法
1649
查看次数

npm http-server 下载 PHP 文件而不是执行它们

正如标题所说,我试图在本地主机上执行一个 PHP 文件,但它只是下载该文件。我正在使用 npm 包 http-server。我曾尝试使用 python 中的 SimpleHTTPServer,但它做同样的事情。

我正在运行 MacOS Mojave。我该怎么办?

php httpserver npm server

2
推荐指数
1
解决办法
1625
查看次数