1 Star 0 Fork 9

冯一航/djc_helper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main_scf.py 1.19 KB
一键复制 编辑 原始数据 按行查看 历史
风之凌殇 提交于 2022-05-14 19:47 . fix: lint
#!/usr/bin/env python
# 云函数入口文件(Serverless Cloud Function,SCF)
# https://cloud.tencent.com/document/product/583/56051
from flask import Flask, request
from main import main_wrapper
app = Flask(__name__)
@app.route("/event-invoke", methods=["POST"])
def invoke():
# Get all the HTTP headers from the official documentation of Tencent
request_id = request.headers.get("X-Scf-Request-Id", "")
print("SCF Invoke RequestId: " + request_id)
event = request.get_data()
event_str = event.decode("utf-8")
print(f"SCF event function input: {event_str} request_id: {request_id}\n")
main_wrapper()
return f"{event_str} request_id: {request_id} completed"
@app.route("/web-invoke/python-flask-http", methods=["POST", "GET"])
def web_invoke():
# Get all the HTTP headers from the official documentation of Tencent
request_id = request.headers.get("X-Scf-Request-Id", "")
print("SCF Invoke RequestId: " + request_id)
event = request.get_data()
event_str = event.decode("utf-8")
return "Hello from SCF HTTP function, your input: " + event_str + ", request_id: " + request_id + "\n"
if __name__ == "__main__":
app.run(host="0.0.0.0", port=9000)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/cooingA/djc_helper.git
git@gitee.com:cooingA/djc_helper.git
cooingA
djc_helper
djc_helper
master

搜索帮助