-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from devsapp/add-other-examples
Add other examples
- Loading branch information
Showing
27 changed files
with
374 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Type: Application | ||
Name: start-fc-mongodb-python | ||
Version: 0.0.2 | ||
Provider: | ||
- 阿里云 | ||
Description: 快速部署一个 Python 访问 mongodb 的函数到阿里云函数计算。 | ||
HomePage: https://github.com/devsapp/start-fc-db-python | ||
Tags: | ||
- 函数计算 | ||
- 你好世界 | ||
- 新手入门 | ||
Category: 新手入门 | ||
Service: | ||
函数计算: | ||
Authorities: | ||
- 创建函数 | ||
- 删除函数 | ||
- 创建服务 | ||
- 删除服务 | ||
Runtime: Python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# 阿里云函数计算 Python 访问 mongodb 数据库 | ||
|
||
只需几步就可以快速在阿里云函数计算服务上体验 Python 访问 mongodb 数据库 | ||
|
||
- 初始化项目:`s init start-fc-mongodb-python -d start-fc-mongodb-python` | ||
- 进入项目:`cd start-fc-mongodb-python` | ||
- 将 s.yaml 中的环境变量修改成您自己的值, 并将数据库操作代码改成您需要的 | ||
- 构建项目:`s build --use-docker` | ||
- 部署项目:`s deploy` | ||
- 触发项目:`s invoke` | ||
|
||
即可实现`Python 访问 mongodb`案例的初始化、部署整个流程。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
import os | ||
from pymongo import MongoClient | ||
|
||
|
||
def handler(event, context): | ||
dbName = os.environ['MONGO_DATABASE'] | ||
url = os.environ['MONGO_URL'] | ||
|
||
client = MongoClient(url) | ||
|
||
col = client[dbName]['fc_col'] | ||
col.insert_one(dict(DEMO="FC", MSG="Hello FunctionCompute For MongoDB")) | ||
doc = col.find_one(dict(DEMO="FC")) | ||
print('find documents:' + str(doc)) | ||
return str(doc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pymongo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# 阿里云函数计算 Python 访问 mongodb 数据库 | ||
|
||
只需几步就可以快速在阿里云函数计算服务上体验 Python 访问 mongodb 数据库 | ||
|
||
- 初始化项目:`s init start-fc-mongodb-python -d start-fc-mongodb-python` | ||
- 进入项目:`cd start-fc-mongodb-python` | ||
- 将 s.yaml 中的环境变量修改成您自己的值, 并将数据库操作代码改成您需要的 | ||
- 构建项目:`s build --use-docker` | ||
- 部署项目:`s deploy` | ||
- 触发项目:`s invoke` | ||
|
||
即可实现`Python 访问 mongodb`案例的初始化、部署整个流程。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
edition: 1.0.0 # 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范 | ||
name: fcDeployApp # 项目名称 | ||
access: "{{ access }}" # 秘钥别名 | ||
|
||
services: | ||
fc-db-mongodb-python: # 服务名称 | ||
component: devsapp/fc # 组件名称 | ||
props: # 组件的属性值 | ||
region: cn-hangzhou | ||
service: | ||
name: fc-db-demo | ||
description: 'demo for fc visit db' | ||
internetAccess: true | ||
function: | ||
name: mongodb | ||
description: visit mongodb | ||
runtime: python3 | ||
codeUri: ./code | ||
handler: index.handler | ||
memorySize: 256 | ||
timeout: 60 | ||
environmentVariables: | ||
MONGO_DATABASE: <your mongo database> | ||
MONGO_URL: <your mongo url> | ||
# 函数计算FC组件文档参考地址:https://github.com/devsapp/fc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- 新版本支持 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Type: Application | ||
Name: start-fc-redis-python | ||
Version: 0.0.2 | ||
Provider: | ||
- 阿里云 | ||
Description: 快速部署一个 Python 访问 redis 的函数到阿里云函数计算。 | ||
HomePage: https://github.com/devsapp/start-fc-db-python | ||
Tags: | ||
- 函数计算 | ||
- 你好世界 | ||
- 新手入门 | ||
Category: 新手入门 | ||
Service: | ||
函数计算: | ||
Authorities: | ||
- 创建函数 | ||
- 删除函数 | ||
- 创建服务 | ||
- 删除服务 | ||
Runtime: Python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# 阿里云函数计算 Python 访问 redis 数据库 | ||
|
||
只需几步就可以快速在阿里云函数计算服务上体验 Python 访问 redis 数据库 | ||
|
||
- 初始化项目:`s init start-fc-redis-python -d start-fc-redis-python` | ||
- 进入项目:`cd start-fc-redis-python` | ||
- 将 s.yaml 中的环境变量修改成您自己的值, 并将数据库操作代码改成您需要的 | ||
- 构建项目:`s build --use-docker` | ||
- 部署项目:`s deploy` | ||
- 触发项目:`s invoke` | ||
|
||
即可实现`Python 访问 redis`案例的初始化、部署整个流程。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
import os | ||
import redis | ||
|
||
conn_pool = None | ||
|
||
|
||
def initializer(context): | ||
global conn_pool | ||
conn_pool = redis.ConnectionPool( | ||
host=os.environ['REDIS_HOST'], password=os.environ['REDIS_PASSWORD'], | ||
port=os.environ['REDIS_PORT'], db=1, decode_responses=True) | ||
|
||
|
||
def handler(event, context): | ||
global conn_pool | ||
r = redis.Redis(connection_pool=conn_pool) | ||
|
||
counter = r.get('counter') | ||
|
||
if counter is None: | ||
counter = 0 | ||
else: | ||
counter = int(counter) | ||
|
||
print('counter: ' + str(counter)) | ||
|
||
r.set('counter', str(counter + 1)) | ||
return counter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# 阿里云函数计算 Python 访问 redis 数据库 | ||
|
||
只需几步就可以快速在阿里云函数计算服务上体验 Python 访问 redis 数据库 | ||
|
||
- 初始化项目:`s init start-fc-redis-python -d start-fc-redis-python` | ||
- 进入项目:`cd start-fc-redis-python` | ||
- 将 s.yaml 中的环境变量修改成您自己的值, 并将数据库操作代码改成您需要的 | ||
- 构建项目:`s build --use-docker` | ||
- 部署项目:`s deploy` | ||
- 触发项目:`s invoke` | ||
|
||
即可实现`Python 访问 redis`案例的初始化、部署整个流程。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
edition: 1.0.0 # 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范 | ||
name: fcDeployApp # 项目名称 | ||
access: "{{ access }}" # 秘钥别名 | ||
|
||
services: | ||
fc-db-redis-python: # 服务名称 | ||
component: devsapp/fc # 组件名称 | ||
props: # 组件的属性值 | ||
region: cn-hangzhou | ||
service: | ||
name: fc-db-demo | ||
description: 'demo for fc visit db' | ||
internetAccess: true | ||
function: | ||
name: redis | ||
description: visit redis | ||
runtime: python3 | ||
codeUri: ./code | ||
handler: index.handler | ||
memorySize: 256 | ||
timeout: 30 | ||
initializationTimeout: 60 | ||
initializer: index.initializer | ||
environmentVariables: | ||
REDIS_HOST: <your redis host> | ||
REDIS_PASSWORD: <your redis pwd> | ||
REDIS_PORT: <your redis port> | ||
# 函数计算FC组件文档参考地址:https://github.com/devsapp/fc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- 新版本支持 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Type: Application | ||
Name: start-fc-sql-server-python | ||
Version: 0.0.2 | ||
Provider: | ||
- 阿里云 | ||
Description: 快速部署一个 Python 访问 sql-server 的函数到阿里云函数计算。 | ||
HomePage: https://github.com/devsapp/start-fc-db-python | ||
Tags: | ||
- 函数计算 | ||
- 你好世界 | ||
- 新手入门 | ||
Category: 新手入门 | ||
Service: | ||
函数计算: | ||
Authorities: | ||
- 创建函数 | ||
- 删除函数 | ||
- 创建服务 | ||
- 删除服务 | ||
Runtime: Python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# 阿里云函数计算 Python 访问 sql server 数据库 | ||
|
||
只需几步就可以快速在阿里云函数计算服务上体验 Python 访问 mysql 数据库 | ||
|
||
- 初始化项目:`s init start-fc-sql-server-python -d start-fc-sql-server-python` | ||
- 进入项目:`cd start-fc-sql-server-python` | ||
- 将 s.yaml 中的环境变量修改成您自己的值, 并将数据库操作代码改成您需要的 | ||
- 构建项目:`s build --use-docker` | ||
- 部署项目:`s deploy` | ||
- 触发项目:`s invoke` | ||
|
||
即可实现`Python 访问 sql server`案例的初始化、部署整个流程。 |
Oops, something went wrong.