時間:2023-05-31 12:03:01 | 來源:網(wǎng)站運營
時間:2023-05-31 12:03:01 來源:網(wǎng)站運營
用 Serverless 搭建個人靜態(tài)相冊網(wǎng)站:日常生活中我們經(jīng)常會拍攝一些視頻、照片等,這些文件會占用比較多的存儲空間。本文將介紹一種方法:利用 ThumbsUp 工具,結(jié)合 Serverless Framework 的 component 快速搭建個人相冊網(wǎng)站,為存儲空間減壓。$ npm install -g serverless
2. 安裝 ThumbsUp$ npm install -g thumbsup
3. 初始化項目$ mkdir photos$ thumbsup --input ./photos/ --output website
初始化成功后,可以看到項目目錄結(jié)構(gòu):.├── photos└── website └── index.html
serverless.yml
文件touch serverless.yml
將以下內(nèi)容寫入上述的 yml 文件里:# serverless.ymlmyWebsite: component: "@serverless/tencent-website" inputs: code: src: ./website index: index.html error: index.html region: ap-guangzhou bucketName: my-bucket-1111
配置完成后,文件目錄如下:.├── photos├── website| └── index.html└── serverless.yml
sls
命令進行部署,并可以添加 --debug
參數(shù)查看部署過程中的信息sls --debug DEBUG ─ Resolving the template's static variables. DEBUG ─ Collecting components from the template. DEBUG ─ Downloading any NPM components found in the template. DEBUG ─ Analyzing the template's components dependencies. DEBUG ─ Creating the template's components graph. DEBUG ─ Syncing template state. DEBUG ─ Executing the template's components graph. DEBUG ─ Starting Website Component. DEBUG ─ Preparing website Tencent COS bucket my-bucket-thumbsup-1256386184. DEBUG ─ Deploying "my-bucket-thumbsup-1256386184" bucket in the "ap-guangzhou" region. DEBUG ─ "my-bucket-thumbsup-1256386184" bucket was successfully deployed to the "ap-guangzhou" region. DEBUG ─ Setting ACL for "my-bucket-thumbsup-1256386184" bucket in the "ap-guangzhou" region. DEBUG ─ Ensuring no CORS are set for "my-bucket-thumbsup-1256386184" bucket in the "ap-guangzhou" region. DEBUG ─ Ensuring no Tags are set for "my-bucket-thumbsup-1256386184" bucket in the "ap-guangzhou" region. DEBUG ─ Configuring bucket my-bucket-thumbsup-1256386184 for website hosting. DEBUG ─ Uploading website files from D:/tencent-serverless/thumbsup/website to bucket my-bucket-thumbsup-1256386184. DEBUG ─ Starting upload to bucket my-bucket-thumbsup-1256386184 in region ap-guangzhou DEBUG ─ Uploading directory D:/tencent-serverless/thumbsup/website to bucket my-bucket-thumbsup-1256386184 DEBUG ─ Website deployed successfully to URL: http://my-bucket-thumbsup-1256386184.cos-website.ap-guangzhou.myqcloud.com. myWebsite: url: http://my-bucket-thumbsup-1256386184.cos-website.ap-guangzhou.myqcloud.com env: 13s ? myWebsite ? done
訪問命令行輸出的 website url,即可查看即可查看使用 Serverless Framework 部署的照片墻網(wǎng)站。注:如果希望更新網(wǎng)站中的照片或者視頻等文件,可以在 photos 文件夾更新照片后,在本地重新運行thumbsup --input ./photos/ --output website
更新本地頁面,再運行sls
即可更新網(wǎng)站。
傳送門:
關(guān)鍵詞:靜態(tài),相冊
微信公眾號
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。