In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Based on Serverless + WeCom how to create a nCoV epidemic monitoring assistant, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.
Some of the recent epidemic information is very worrying, in order to facilitate everyone to grasp the epidemic information, in his spare time to do a nCoV epidemic monitoring assistant.
Realize the effect
First of all, what we need to solve is the problem of data source, here we can use python crawler to do this, but because individuals are lazy, we directly use 2019-nCoV-Crawler, this project has integrated the existing API, so we can call it directly. Of course, capable students can also deploy their own Python, my side is my own deployment, but this is not the focus of this time, I will not repeat it.
Now, we have the data, but how does the data get to the server? How should it be triggered? Of course, it's OK to use CVM, but it seems too clumsy and expensive, and you need to set up all the environments yourself. So, here we choose Serverless to deploy.
Core logic
Let's take a look at the code part of the overall business. After all, this is the core of the whole robot. Let's look at the code (request the interface three times):
Isn't it easy? Request data, send data.
So let's focus on how to upload our business code to the cloud. I use the Tencent Cloud Serverless service SCF cloud function on the cloud here. The whole deployment and use process is free, and the free quota is sufficient for developers to use small projects. You don't have to worry about paying extra.
Serverless deployment, the choice of the more popular Serverless Framework, the use and deployment is also completely free, then I will introduce the specific deployment process.
Install the Serverless framework
First, as a first step, let's install a Serverless Framework development framework:
$npm install-g serverless
Then, we create a function directory:
$mkdir nCov-function$ cd nCov-function
The contents of the related function directory are as follows:
| |-code |-index.php / / this is the location of the business code above |-serverless.yml / / serverless configuration file configuration Yml file |
Next, let's focus on configuring the function yml file:
# serverless.ymlmyFunction: component: "@ serverless/tencent-scf" / / reference tencent-scf component inputs: name: nCoVFunction / / function name enableRoleAuth: true codeUri:. / code / / the local location of the code is handler: index.main_handler runtime: Php5 region: ap-shanghai / / function operation region description: My Serverless nCoV Function. MemorySize: 128Runtime timeout: 20 / / timeout exclude:-.gitignore-.git / * *-node_modules/**-.serverless-.env include: -. / nCoVFunction.zip environment: variables: TEST: vale vpcConfig: subnetId:''vpcId:' 'events: -timer: / / timing trigger name: timer parameters: cronExpression: '010 ~ (21) * / / 10:00 tomorrow morning 21:00 enable: true
When everything is ready, we can deploy SLS directly.
Deploy to the cloud
Deploy through the sls command (short for serverless), and you can add the-debug parameter to view the information during the deployment process:
Taborchen$ sls-debug 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 nCoVFunction file to / Users/taborchen/Desktop/ work / yiqing/.serverless/nCoVFunction.zip. DEBUG ─ Compressed function nCoVFunction file successful DEBUG ─ Uploading service package to cos [sls-cloudfunction-ap-shanghai-code]. Sls-cloudfunction-default-nCoVFunction-1580960644.zip DEBUG ─ Uploaded package successful / Users/taborchen/Desktop/ work / yiqing/.serverless/nCoVFunction.zip DEBUG ─ Creating function nCoVFunction DEBUG ─ Created function nCoVFunction successful DEBUG ─ Setting tags for function nCoVFunction DEBUG ─ Creating trigger for function nCoVFunction DEBUG Created timer trigger timer for function nCoVFunction success. DEBUG ─ Deployed function nCoVFunction successful
The running results are as follows:
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.