create account

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

View this thread on: hive.blogpeakd.comecency.com
· @lemooljiang ·
$0.94
用IPFS做个小网站 / 网络研习社#37
![ipfs6.jpg](https://cdn.steemitimages.com/DQmcrWYebEGD6uW9eaLj4xSBMia3sMvyVHfpNKCdsrPWULb/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](https://cdn.steemitimages.com/DQmcdLsNBDmdNCkhDakwXd7hCNXUy8ZTJHgKDrkX6QvV1Fm/ipfs5.jpg)

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

好了,你可以试试,做一个相对功能精简的网站还是比较容易的。
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorlemooljiang
permlinkipfs-37
categorycn
json_metadata{"tags":["cn","network-institute","ipfs","hash","site"],"image":["https://cdn.steemitimages.com/DQmcrWYebEGD6uW9eaLj4xSBMia3sMvyVHfpNKCdsrPWULb/ipfs6.jpg","https://cdn.steemitimages.com/DQmcdLsNBDmdNCkhDakwXd7hCNXUy8ZTJHgKDrkX6QvV1Fm/ipfs5.jpg"],"app":"steemit/0.1","format":"markdown"}
created2019-08-22 09:26:03
last_update2019-08-22 09:26:03
depth0
children2
last_payout2019-08-29 09:26:03
cashout_time1969-12-31 23:59:59
total_payout_value0.529 HBD
curator_payout_value0.413 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length765
author_reputation441,276,560,324,266
root_title"用IPFS做个小网站 / 网络研习社#37"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,818,938
net_rshares4,076,718,794,417
author_curate_reward""
vote details (46)
@scisan ·
$0.17
网速还可以啊,可以一试!
👍  , ,
properties (23)
authorscisan
permlinkpwp3s4
categorycn
json_metadata{"tags":["cn"],"app":"steemit/0.1"}
created2019-08-23 15:16:45
last_update2019-08-23 15:16:45
depth1
children0
last_payout2019-08-30 15:16:45
cashout_time1969-12-31 23:59:59
total_payout_value0.085 HBD
curator_payout_value0.084 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length12
author_reputation-1,481,395,934,280
root_title"用IPFS做个小网站 / 网络研习社#37"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,866,857
net_rshares806,993,955,744
author_curate_reward""
vote details (3)
@steemitboard ·
Congratulations @lemooljiang! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

<table><tr><td><img src="https://steemitimages.com/60x70/http://steemitboard.com/@lemooljiang/votes.png?201908240406"></td><td>You distributed more than 29000 upvotes. Your next target is to reach 30000 upvotes.</td></tr>
</table>

<sub>_You can view [your badges on your Steem Board](https://steemitboard.com/@lemooljiang) and compare to others on the [Steem Ranking](https://steemitboard.com/ranking/index.php?name=lemooljiang)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



###### [Vote for @Steemitboard as a witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1) to get one more award and increased upvotes!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-lemooljiang-20190824t044853000z
categorycn
json_metadata{"image":["https://steemitboard.com/img/notify.png"]}
created2019-08-24 04:48:51
last_update2019-08-24 04:48:51
depth1
children0
last_payout2019-08-31 04:48:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length862
author_reputation38,975,615,169,260
root_title"用IPFS做个小网站 / 网络研习社#37"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,887,234
net_rshares0