互联网计算机的 Dfinity 快速入门

Dfinity Quickstart for internet computer

我一直在尝试让快速入门工作,但各种 dfx 命令似乎无法生成应用程序所需的必要 html 页面和 css 文件。当您在本地部署容器,然后在 http://localhost:8000/?canisterId=xxx 调用它而不是生成网页时,它只显示 javascript 消息和对话框。

根据快速入门,当您 运行 dfx canister install --all 时,您应该得到一个看起来像

的日志
 Installing code for canister explore_hello, with canister_id rrkah-fqaaa-aaaaa-aaaaq-cai
Installing code for canister explore_hello_assets, with canister_id ryjl3-tyaaa-aaaaa-aaaba-cai
Authorizing our identity (pubs-id) to the asset canister...
Uploading assets to asset canister...
  /index.html 1/1 (480 bytes)
  /index.js 1/1 (296836 bytes)
  /main.css 1/1 (484 bytes)
  /sample-asset.txt 1/1 (24 bytes)
  /logo.png 1/1 (25397 bytes)
  /index.js.map 1/1 (964679 bytes)
  /index.js.LICENSE.txt 1/1 (499 bytes)
 

我得到的只是:

Installing code for canister explore_hello, with canister_id rrkah-fqaaa-aaaaa-aaaaq-cai
Installing code for canister explore_hello_assets, with canister_id ryjl3-tyaaa-aaaaa-aaaba-cai
Authorizing our identity (default) to the asset canister...
Uploading assets to asset canister...

然后它只是 returns 到终端提示,显然没有上传资产。也没有 index.html 或 'main.css` file in my hello-assets assets directory. You can load the page at the appropriate url (http:localhost:8000/?canisterId=' 但你没有得到一个页面,你只是得到 javascript 提示

如果你只是想启动一个静态的简单网站,你可以使用fleek.co's free service dedicated for hosting website on IC. It helps you create a canister, automate deployment from local repo to Github, and can support a variety of frontend frameworks such as Gatsby。您的站点将部署在 Internet 计算机 上,地址为 https://xxxxx-xxxxx-xxxxx-xxxxx-cai.ic0.app

例如,我刚刚用这种方法为 DFINITY 相关站点 Internet Computer Big Bang! 创建了一个单页导航页面。 index.html 页面准备就绪后,只需几分钟即可在 IC 上启动该网站。我发现使用 fleek.co 以这种方式部署比遵循 DFINITY 的官方教程要容易得多。

从 dfx v0.8 开始,快速入门 (https://sdk.dfinity.org/docs/quickstart/local-quickstart.html) 对我来说运行良好。

根据文档,对于首次安装:

  1. dfx new //创建默认的 hello world 布局
  2. CD
  3. npm 安装
  4. dfx 部署