Nodejs Shortener Code don Chromium工作

发布于 2025-01-26 09:07:08 字数 681 浏览 2 评论 0原文

我想使我的代码更短。在这种情况下,我将此

const s_html = 'text/html';
const s_png = 'image/png';
const s_jpg = 'image/jpg';
const s_jpeg = 'image/jpeg';
const s_css = 'text/css';
const s_js = 'text/javascript';

缩写功能

function datatype(file, filetype) {
  fs.readFile(file, function(err,data){res.writeHead(200, {'Content-Type': filetype}); res.write(data); res.end();})
  }

制成了,我允许

case '/static/toolkit.js':
datatype("./static/toolkit.js", "s_js");
break;

在运行代码后进行此操作,我的网站不会显示样式,但是CSS代码可以在Inspect>源中可用

,没有错误或缺少某些内容。后来,我在Firefox上连接我的网站,这是无缝的。

那么那里有什么问题?在我的浏览器中有问题吗?因为我在debian中使用了无聊的铬

I want to make shorter my code. In this case I maked this

const s_html = 'text/html';
const s_png = 'image/png';
const s_jpg = 'image/jpg';
const s_jpeg = 'image/jpeg';
const s_css = 'text/css';
const s_js = 'text/javascript';

My Shortener Function

function datatype(file, filetype) {
  fs.readFile(file, function(err,data){res.writeHead(200, {'Content-Type': filetype}); res.write(data); res.end();})
  }

After, I allowed to make this

case '/static/toolkit.js':
datatype("./static/toolkit.js", "s_js");
break;

After run my code, My website don't show style but css code is available in Inspect>Source

There is no wrong or missing something. Later on I connect my website on Firefox and it was seamless.

So what's the problem there? Is it problem in my browser? Because I use ungoogled chromium in debian

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文