Giter Club home page Giter Club logo

tencent-bottle's Introduction

Serverless Bottle Tencent Cloud

 

腾讯云 Bottle Serverless Component

简介

腾讯云 Bottle Serverless Component, 支持 Restful API 服务的部署.

目录

  1. 准备
  2. 安装
  3. 配置
  4. 部署
  5. 移除

0. 准备 `

安装Bottle,新建python文件,例如app.py

from bottle import route, run, template

@route('/hello/<name>')
def index(name):
    return template('<b>Hello {{name}}</b>!', name=name)

并将python所需要的依赖安装到项目目录,例如本实例需要bottle,所以可以通过pip进行安装:

pip install bottle -t ./

如果因为网络问题,可以考虑使用国内源,例如:

pip install bottle -t ./ -i https://pypi.tuna.tsinghua.edu.cn/simple

1. 安装

通过 npm 全局安装 serverless cli

$ npm install -g serverless

2. 配置

本地创建 serverless.yml 文件,在其中进行如下配置

$ touch serverless.yml
BottleTest:
  component: '@serverless/tencent-bottle'
  inputs:
    region: ap-guangzhou
    functionName: BottleFunctionTest
    code: ./
    functionConf:
      timeout: 10
      memorySize: 256
      environment:
        variables:
          TEST: vale
      vpcConfig:
        subnetId: ''
        vpcId: ''
    apigatewayConf:
      protocols:
        - http
      environment: release

3. 部署

如您的账号未 登陆注册 腾讯云,您可以直接通过 微信 扫描命令行中的二维码进行授权登陆和注册。

通过 sls 命令进行部署,并可以添加 --debug 参数查看部署过程中的信息

$ sls --debug

4. 移除

通过以下命令移除部署的服务

$ sls remove --debug

账号配置(可选)

当前默认支持 CLI 扫描二维码登录,如您希望配置持久的环境变量/秘钥信息,也可以本地创建 .env 文件

$ touch .env # 腾讯云的配置信息

.env 文件中配置腾讯云的 SecretId 和 SecretKey 信息并保存

如果没有腾讯云账号,可以在此 注册新账号

如果已有腾讯云账号,可以在 API 密钥管理 中获取 SecretIdSecretKey.

# .env
TENCENT_SECRET_ID=123
TENCENT_SECRET_KEY=123

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.