快速部署静态网站,将自定义的Web页面托管到对象存储COS中,并生成域名供外网访问。
# 安装
npm install -g serverless
# 创建
本地创建demo文件夹
mkdir demo
$ cd demo
文件夹中创建对应的 serverless.yml 文件,并将静态页面放在code目录下
touch serverless.yml
静态页面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello</title>
</head>
<body>
Hello
</body>
</html>
# 配置
serverless.yml
myWebsite:
component: "@serverless/tencent-website"
inputs:
code:
src: ./code
index: index.html
error: index.html
region: ap-guangzhou
bucketName: my-bucket
# 部署
sls命令进行部署,可以添加--debug参数查看部署信息
# 移除
sls remove --debug
# 根据 Serverless Framework 构建疫情数据展示页
- serverless create --template-url https://github.com/tinafangkunding/nCov-page
- cd nCov-page
- npm run bootstrap
- serverless --debug
部署详情
dashboard:
url: http://moekrl8-h5514cps-1256464567.cos-website.ap-guangzhou.myqcloud.com
env:
apiUrl: https://service-eliq2qck-1256464567.gz.apigw.tencentcs.com/release/
apiUrlSZ: https://myapi.ihogu.com/public/?s=Whfy.city&city=%E6%B7%B1%E5%9C%B3
api:
region: ap-guangzhou
functionName: tencent-fullstack-vue-api
apiGatewayServiceId: service-eliq2qck
url: https://service-eliq2qck-1256464567.gz.apigw.tencentcs.com/release/
64s › dashboard › done