indexzero/http-server-2-使用
生活随笔
收集整理的這篇文章主要介紹了
indexzero/http-server-2-使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
所以在ethereumjs-vm/examples/run-transactions-simple例子中要怎么使用http-server
1.首先在ethereumjs-vm/examples/run-transactions-simple目錄下將http-server運行起來:
userdeMBP:run-transactions-simple user$ http-server Starting up http-server, serving ./ Available on:http://127.0.0.1:8080http://192.168.199.233:8080 Hit CTRL-C to stop the server?
2.然后就能夠在瀏覽器中訪問當前目錄下的文件了,首先可以查看一個該目錄下有什么文件:
userdeMBP:run-transactions-simple user$ ls README.md bundle.js index.html index.js?
3.然后在瀏覽器中訪問http://127.0.0.1:8080,就會自動訪問到當前目錄下的index.html文件:
服務器返回:
userdeMBP:run-transactions-simple user$ http-server Starting up http-server, serving ./ Available on:http://127.0.0.1:8080http://192.168.199.233:8080 Hit CTRL-C to stop the server [Wed Dec 12 2018 14:12:22 GMT+0800 (中國標準時間)] "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" [Wed Dec 12 2018 14:12:22 GMT+0800 (中國標準時間)] "GET /bundle.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" [Wed Dec 12 2018 14:12:23 GMT+0800 (中國標準時間)] "GET /favicon.ico" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" [Wed Dec 12 2018 14:12:23 GMT+0800 (中國標準時間)] "GET /favicon.ico" Error (404): "Not found"瀏覽器返回:
?
如果當前目錄下沒有index.html文件,將返回:
這就是你打開http-server的當前目錄的所有文件和文件夾,然后就能夠通過點擊進行訪問。因為我將index.html放到了views文件夾下,點擊views文件夾,就能夠訪問index.html了:
?
4.訪問http://127.0.0.1:8080/index.js
就能夠在瀏覽器打開index.js文件
?
使用http-server的好處就是能夠十分快速地開啟一個服務器,并能夠在瀏覽器上給出當前目錄的所有文件,可以通過點擊進行調用
轉載于:https://www.cnblogs.com/wanghui-garcia/p/10109401.html
總結
以上是生活随笔為你收集整理的indexzero/http-server-2-使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Confluence 6 归档一个空间
- 下一篇: 上币至iamToken