小编Pet*_*rek的帖子

用于生产的 Python http 服务器

Python 文档声称,“不建议将 http.server 用于生产。它只实现基本的安全检查。”

是否有另一个简单易用的 python 服务器(如 http.server),具有“高级”安全检查,可以用于生产?

(我想在 Raspberri Pi 上运行 http 服务器,它将为静态网站提供服务)

谢谢!

python security httpserver python-3.x

13
推荐指数
1
解决办法
7516
查看次数

服务器发送的事件生成错误 ERR_INCOMPLETE_CHUNKED_ENCODING

我有 ExpressJS 服务器(在 NodeJS 中),它使用服务器发送的事件来宣布服务器数据库的更改。

我的 NodeJS 应用程序中的实际处理程序如下所示:

this._app.use((req, res, next) => {
    if (req.url.includes("addDBListener")) {
        res.writeHead(200, {
            'Content-Type': 'text/event-stream',
            'Cache-Control': 'no-cache',
            'Connection': 'keep-alive'
        });
        res.write('\n\n');
        let path = (req.query && req.query.path) ? req.query.path : "";
        this.dbListeners.push({
           path: path,
           res: res
        });
    }
    else {
        next();
    }
});
Run Code Online (Sandbox Code Playgroud)

然后,当数据库发生任何更改时,我以这种方式向客户端发送信息(“i”是客户端的索引,我向其发送新信息):

this.clientDBListeners[i].res.write("data: " + JSON.stringify(DBPart) + "\n\n");
Run Code Online (Sandbox Code Playgroud)

在客户端,我用它来初始化(和处理)事件处理:

source = new EventSource('/addDBListener?path=' + dbPath)

let messageHandler = (e)=> {
    console.log("DATAA: "+e.data);
}

let errorHandler = (e)=> { 
    //process error
    console.log("ERROR!!!");
}

source.addEventListener('message', …
Run Code Online (Sandbox Code Playgroud)

javascript node.js express server-sent-events typescript

5
推荐指数
0
解决办法
540
查看次数

如何将Bootstrap变量导入SASS模块?

有没有办法在 SASS 模块中使用 Bootstrap SASS 变量?

例如,我的react/NextJS 项目中有文件index.module.scss。如何在 bootstrap 中使用 sass 模块变量?像这样的事情:

.hero{
    color: $blue-200;
}
Run Code Online (Sandbox Code Playgroud)

如果我只是在文件开头添加此导入:

@import '~bootstrap/scss/bootstrap.scss';
Run Code Online (Sandbox Code Playgroud)

我收到此错误(来自 NextJS): 在此输入图像描述

让我注意到,当我在非模块 sass 文件中使用此导入(假设在文件 index.scss 中)时,它会起作用。但我需要(想要)使用 SASS 模块......

知道如何解决吗?
谢谢!

sass reactjs css-modules next.js bootstrap-5

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