用IPFS做个小网站 / 网络研习社#37

in #cn7 years ago

ipfs6.jpg

https://ap.siderus.io/ipfs/QmT5UJ1vm7J3jDo3Yq6jcoxzt2CCk8GQ1jiZQJSEcE1Vd3

有了上一篇中的IPFS基础,用它来做个小网站也是可行的,毕竟它是完全免费且分布式的哦。

制作一个小网站

新建一个文件夹site,在里面填充一个网站要具备的文件,比如index.html style.css .jpeg等等。这些静态文件上传到IPFS上,会得到对应的hash值,再以公共网关去访问就可以了。

上传

ipfs add -r site 用这条命令上传你的静态网站文件夹site。注意你的IPFS节点要在后台运行哦,也就是ipfs daemon要一直运行。

访问

gateway + site_hash 用这种格式去访问你的网站。

ipfs5.jpg

如上图所示,这是我上传文件夹site得到的hash值。每个文件都会产生对应的hash值,用最后那个site文件夹的hash值去访问网站,比如这样:https://ap.siderus.io/ipfs/QmT5UJ1vm7J3jDo3Yq6jcoxzt2CCk8GQ1jiZQJSEcE1Vd3

好了,你可以试试,做一个相对功能精简的网站还是比较容易的。

Sort:  

Congratulations @lemooljiang! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You distributed more than 29000 upvotes. Your next target is to reach 30000 upvotes.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Vote for @Steemitboard as a witness to get one more award and increased upvotes!
 7 years ago  Reveal Comment