问题描述
我有一个裸机应用程序,该应用程序在带有10BASE-T以太网(CS8900)的微型16位微控制器(St10)上运行,并基于EasyWeb项目实现了Tcp/IP.
I have a bare-metal application running on a tiny 16 bit microcontroller (St10) with 10BASE-T Ethernet (CS8900) and a Tcp/IP implementation based upon the EasyWeb project.
实现了一个微型Web服务器,用于显示设备的某些状态信息,并且还可以更改设置等.
There is a tiny webserver implemented for displaying some status information of the device and also allows to change settings et cetera.
为了访问浏览器,网络服务器提供了一些文件,例如index.html
,*.css
,*.js
,*.svg
,*.png
等.
For browser access, the webserver provides some files like index.html
, *.css
, *.js
, *.svg
, *.png
and so on.
由于裸机目标没有像sd卡那样的存储介质,因此我将上述所有资源都放入了已编译的二进制文件中.
As the bare-metal target has no storage media like a sd-card, I put all of the above mentioned resources into the compiled binary.
为了节省内存并减少流量,我将所有文件放在一起使用gzip
压缩为一个index.html
压缩文件,然后让我的网络服务器使用Content-Encoding: gzip
进行压缩.
For saving memory and reducing traffic, I put all of the files together into a single index.html
compress that using gzip
and let my webserver deliver this using Content-Encoding: gzip
.
将所有文件放到单个index.htm
中的步骤目前是手动操作(包括替换文件名引用等).会不会有一种工具可以自动执行此操作?
The step to put all the files together into single index.htm
is currently manual work (incl. replace filename references et cetera). Might there be a tool which do this automatically?
或者,我是否可以将zip/tar/所有文件压缩成一个文件,并根据http GET /
请求将其交付?
Or alternatively, can I just zip / tar / whatever all the files into a single file and deliver this upon http GET /
request?
编辑2017-10-05
使用 innerer 解决/a/46512245/2880699> brain99 .
Solved by using the inliner mentioned by brain99.
使其在Kubuntu 16.04主机上运行时遇到了一些小麻烦,但最终通过安装进行了修复:
Having small trouble making it run on Kubuntu 16.04 host but finally fixed it by installing:
sudo apt-get install nodejs
sudo ln -sT "$(which nodejs)" /usr/local/bin/node
sudo apt-get install npm
sudo npm install -g inliner
也许,我通过使用nodejs-legacy
而不是nodejs
摆脱了符号链接(尚未尝试).安装完之后,我只需要运行:
Maybe, I'd got rid of the symlink by using nodejs-legacy
instead of nodejs
(have not tried).After having installed that, I just need to run:
inliner index.html >index-backed.html
gzip -c index-backed.html >index.html.gz
推荐答案
选项1 :通过Chrome
Option 1: via Chrome
有一组两个Chrome扩展程序,可用于将网页保存为单个HTML文件:
There is a set of two Chrome extensions that allow you to save a webpage to a single HTML file:
- SingleFile
- SingleFile Core
第二个扩展名是第一个扩展名所需的帮助程序扩展名.我没有对此进行测试,但是它似乎在Chrome网上应用店中获得了不错的评价(显然,它在复杂的页面上会令人窒息).
The second extension is a helper extension required by the first one. I did not test this, but it seems to have reasonably good reviews in the Chrome web store (apparently it can choke on complex pages).
有了这些扩展名,您应该只能够在Chrome中打开页面,并使用扩展名将其保存为带有嵌入式CSS/脚本/图像的单个文件.
With these extensions, you should just be able to open the page in Chrome and use the extensions to save as a single file with embedded CSS/scripts/images.
选项2 :可编写脚本
如果您想自动化脚本中的内容,则在github上还有一个项目可以通过npm安装.
If you want to automate things in a script, there is also a project on github exactly for that, which can be installed via npm.
这篇关于如何将网站作为单个文件提供?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!