@app.route('/user', methods = ['POST']) defaddUser(): # we must get request body from clound function event; event = request.environ['event'] user = json.loads(event['body']) return jsonify(data=user)
DEBUG ─ Resolving the template's static variables. DEBUG ─ Collecting components from the template. DEBUG ─ Downloading any NPM components found in the template. DEBUG ─ Analyzing the template's components dependencies. DEBUG ─ Creating the template's components graph. DEBUG ─ Syncing template state. DEBUG ─ Executing the template's components graph. DEBUG ─ Compressing function LAB_Serverless file to D:\yuangezhizao\Documents\PycharmProjects\LAB_Serverless\.serverless/LAB_Serverless.zip. (node:22500) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat'D:\yuangezhizao\Documents\PycharmProjects\LAB_Serverless\. serverless\requirements'eploying at Object.statSync (fs.js:946:3) at Object.statSync (C:\Users\yuangezhizao\AppData\Roaming\npm\node_modules\serverless\node_modules\_graceful-fs@4.2.3@graceful-fs\polyfills.js:308:16 ) at WriteStream.<anonymous> (C:\Users\yuangezhizao\.serverless\components\registry\npm\@serverless\tencent-flask@0.2.0\node_modules\@serverless\tencen t-flask\node_modules\@serverless\tencent-scf\library\utils.js:124:20) at WriteStream.emit (events.js:304:20) at C:\Users\yuangezhizao\.serverless\components\registry\npm\@serverless\tencent-flask@0.2.0\node_modules\@serverless\tencent-flask\node_modules\grac eful-fs\graceful-fs.js:298:14 at C:\Users\yuangezhizao\.serverless\components\registry\npm\@serverless\tencent-flask@0.2.0\node_modules\@serverless\tencent-flask\node_modules\grac eful-fs\graceful-fs.js:325:16 at C:\Users\yuangezhizao\AppData\Roaming\npm\node_modules\serverless\node_modules\_graceful-fs@4.2.3@graceful-fs\graceful-fs.js:325:16 at FSReqCallback.oncomplete (fs.js:152:23) (node:22500) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:22500) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will termi nate the Node.js process with a non-zero exit code.
DEBUG ─ Resolving the template's static variables. DEBUG ─ Collecting components from the template. DEBUG ─ Downloading any NPM components found in the template. DEBUG ─ Analyzing the template's components dependencies. DEBUG ─ Creating the template's components graph. DEBUG ─ Syncing template state. DEBUG ─ Executing the template's components graph. DEBUG ─ Generated requirements from D:\yuangezhizao\Documents\PycharmProjects\LAB_Serverless\requirements.txt in D:\yuangezhizao\Documents\PycharmProje cts\LAB_Serverless\.serverless\requirements.txt... DEBUG ─ Installing requirements from C:\Users\yuangezhizao\AppData\Local\Yugasun\serverless-python-requirements\Cache\2a1a661c4e3e6faadab5d001bc10cc3ac ccf648921aad7c279d94f138eaaf833_slspyc\requirements.txt ... DEBUG ─ Using download cache directory C:\Users\yuangezhizao\AppData\Local\Yugasun\serverless-python-requirements\Cache\downloadCacheslspyc DEBUG ─ Running ... DEBUG ─ Compressing function LAB_Serverless file to D:\yuangezhizao\Documents\PycharmProjects\LAB_Serverless\.serverless/LAB_Serverless.zip. DEBUG ─ Compressed function LAB_Serverless file successful DEBUG ─ Uploading service package to cos[sls-cloudfunction-ap-beijing-code]. sls-cloudfunction-default-LAB_Serverless-1582464464.zip DEBUG ─ Uploaded package successful D:\yuangezhizao\Documents\PycharmProjects\LAB_Serverless\.serverless/LAB_Serverless.zip DEBUG ─ Creating function LAB_Serverless DEBUG ─ Created function LAB_Serverless successful DEBUG ─ Setting tags forfunction LAB_Serverless DEBUG ─ Creating trigger forfunction LAB_Serverless DEBUG ─ Deployed function LAB_Serverless successful DEBUG ─ Starting API-Gateway deployment with name MyComponent.TencentApiGateway in the ap-beijing region DEBUG ─ Service with ID service-0ok85tqh created. DEBUG ─ API with id api-ivk6tk0y created. DEBUG ─ Deploying service with id service-0ok85tqh. DEBUG ─ Deployment successful for the api named MyComponent.TencentApiGateway in the ap-beijing region.
其实这就是serverless的核心了,serverless配置静态页面的原理自己是清楚的 比如Hexo那玩楞,就是生成页面之后扔到COS上就能访问了 但是,对于动态页面就比较好奇了,这是怎么实现的呢,其实就是靠着serverless.wsgi这个文件等等 自然能看到这个模块描述:此模块将 AWS API Gateway 代理请求转换为 WSGI 请求。
1 2 3 4 5 6 7
""" This module converts an AWS API Gateway proxied request to a WSGI request. Inspired by: https://github.com/miserlou/zappa Author: Logan Raarup <logan@logan.dk> """