npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@serverless/tencent-pyramid

v1.0.1

Published

Tencent Cloud Python Pyramid Serverless Component

Downloads

6

Readme

Serverless Pyramid Tencent Cloud

 

腾讯云 Pyramid Serverless Component

简介

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

目录

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

0. 准备 `

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

from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response


def hello_world(request):
    return Response('Hello World!')


with Configurator() as config:
    config.add_route('hello', '/')
    config.add_view(hello_world, route_name='hello')
    app = config.make_wsgi_app()
    
if __name__ == "__main__":
    server = make_server('0.0.0.0', 6543, app)
    server.serve_forever()

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

pip install Pyramid -t ./

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

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

1. 安装

通过 npm 全局安装 serverless cli

$ npm install -g serverless

2. 配置

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

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

注意,这里的pyramidProjectName必须要和你的项目名称一致!

这里要额外说明,pyramidProjectName实际上是包括你app的那个文件即app = config.make_wsgi_app(),并且要确保可以通过文件名.app从外引用该文件。

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