In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to use Serverless Framework Express components to quickly create text translation tools, for this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
A text translation tool is implemented through Serverless Framework's Express Component. This tool is based on Tencent Cloud TMT machine translation tool and supports translation between multiple languages. Click to view the effect of Demo deployment.
How to use Serverless Framework's Express Component to quickly create a text translation tool? Let's try it with the following steps.
1. Installation
Install the latest version of Serverless Framework through npm
$npm install-g serverless2. Create
Create and enter a new directory:
$mkdir express-trans & & cd express-trans
Quickly create the application with the following command and template link:
$serverless create-- template-url https://github.com/tinafangkunding/serverless-translate$ cd serverless-translate
Enter the src directory and execute the following command to install the corresponding dependencies
Cd src & & npm install3. Configuration
Modify .env.example in the template to .env, and obtain and configure Tencent Cloud's SecretId and SecretKey key information in API key management.
# .envTENCENT _ SECRET_ID=123TENCENT_SECRET_KEY=123
You can log in to https://cloud.tencent.com/login or sign up for https://cloud.tencent.com/register Tencent Cloud account.
4. Deployment
Run the following command in the directory under the serverless.yml file to deploy the application
$serverless deploy
After deployment, you can look up the URL address of the application in the output of the command line, and visit the address to view the deployment result. The supported translation language types refer to the interface documentation.
Please scan QR code login from wechat. Wait login...Login successful for TencentCloud. Serverless ⚡ frameworkAction: "deploy"-Stage: "dev"-App: "appDemo"-Instance: "TranslateDemo" region: ap-beijingapigw: serviceId: service-xxxxx subDomain: service-xxxxx-1250000000.bj.apigw.tencentcs.com environment: release url: https://service-xxxxx-1250000000.bj.apigw.tencentcs.com/release/scf: functionName: express_component_xxxx runtime: Nodejs10.15 namespace: default10s > TranslateDemo > Success
For example, https://service-q8qqunpf-1251971143.bj.apigw.tencentcs.com/release/ inputs serverless and translates it into zh simplified Chinese, and the input language is automatically monitored. Translation result: no server
5. Monitor and control
View application-level monitoring information in Serverless Dashboard. Currently, the following monitoring metrics are displayed:
Function triggers / errors: function invocations & errors
Function delay: function latency
Number of API requests / errors: api requests & errors
API request delay: api latency
Number of API 5xx errors: api 5xx errors
Number of API 4xx errors: api 4xx errors
API error count: api errors
Statistics of request method, number of requests and average delay of API under different paths: api path requests
6. Remove
In the directory where the serverless.yml file is located, remove the deployed Express service with the following command. After removal, the component corresponds to the deletion of all related resources created when deployed on the cloud.
This is the answer to serverless remove's question on how to quickly create a text translation tool using Serverless Framework Express components. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
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.