当前位置:网站首页>8 lines of code to teach you how to build an intelligent robot platform

8 lines of code to teach you how to build an intelligent robot platform

2022-06-24 13:18:00 Brother tortoise

In our traditional application development , It is basically necessary to deploy an application server , And by serverless There is no need to build a server to deploy our own applications , There is no need to deploy the corresponding environment , Just a few lines of code are required to deploy our application online . Don't talk much , Let's show you the effect picture first .

Insert picture description here

Above is an intelligent calculator application , adopt 8 With a line of code, we can deploy our own smart calculator , Of course, you can also experience other interesting functions .

1 preparation

  1. linux,mac Such as the environment ( Just have one of them , It can't be windows), without , use ubuntu Virtual machine or linux Web servers can also ( Not necessary ), Today we mainly introduce the use of ubuntu The way virtual machines work
  2. Flybook open platform account registration
  3. Flying book download 1.1 Some reference links
  4. vmware Install Links :https://my.vmware.com/cn/web/vmware/downloads
  5. ubuntu18.04 Image download :http://mirrors.aliyun.com/ubuntu-releases/18.04.5/
  6. rust Environment configuration link :https://github.com/secondstate/serverlessreactorstarter/blob/main/README.md
  7. Flying book download windows App download link :https://www.feishu.cn/download
  8. Flybook open platform account registration :https://passport.feishu.cn/create 6.Serverless Reactor Official website : http://reactor.secondstate.info/2 Create robot application based on flybook open platform 2.1 Fly book open platform account registration click the link :https://passport.feishu.cn/create/?redirect_uri=https%3A%2F%2Fopen.feishu.cn%2Fapp%2Fcli_a02624f5b838d013%2Fevent&app_id=7&lang=zh-CN
    After registration, use the mobile number to log in

Flybook open platform main interface

2.2 Create robot applications

Click on Create an

Create enterprise self built applications

Fill in the application basic information , Click OK to create

The current app is in the pending status

2.3 Configure robot application information

Click the application just created , Click on robot

Click enable robot

3 Serverless Reactor Configure flybook application

Serverless Reactor Facing the flying book 、Slack、 Developers of instant messaging tools such as nail , Provide developers with the development experience of quickly building online third-party applications . adopt Serverless Reactor, Developers only need to focus on the implementation of business logic , There is no need to build an application server 、 Domain name filing 、 Data storage and other cumbersome processes . Program usage WebAssembly(WASM) distribution ,runtime Use WasmEdge-napi, Give developers greater freedom of language choice , And ensure the implementation efficiency .

The specific process is as follows :

Developers put every... Required by the flybook platform callback Write it as a function

The developer uploads the function code to Serverless Reactor platform , Receive a callback URL

Developers put this callback URL Filling in the flybook platform requires callback The place of

register Serverless Reactor account number ( Register via email )

Insert picture description here

After registration, the email will receive a link , Click verify , Then log in

Log in to the home page

Click on the top left corner apps

Click Create new app

Fill in the welcome message and click finish

The welcome message is json Format , Displays when the robot is enabled

In the list, you can see the application we just created

4 Upload the user-defined function configuration file

The default here is that you have already set up ubuntu Virtual machine environment

4.1 install nmp Environmental Science

Enter the following command at the terminal

curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -
yum install -y nodejs
npm install -g cnpm --registry=https://registry.npm.taobao.org
npm install
npm run build
npm -v

4.2 To configure rust and rustwasmc Environmental Science

Enter the following command at the terminal to install rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Enter the following command at the terminal to install rustwasmc( Administrator mode , You need to enter a password )

sudo npm install -g rustwasmc  --unsafe-perm 

4.3 fork Calculator source code to local

github link :https://github.com/second-state/serverless-reactor-starter

download zip Compress the package locally

unpack

Files generated after decompression

Open the terminal in the folder

Right click in the folder and select open in terminal

Enter the following command

rustwasmc bulid

After compiling, you can see that there is one more in the original folder pkg Folder

It produces what we need to go to bed .wasm file

4.4 Upload .wasm file

go back to Serverless Reactor main interface , Click on upload wasm file

Will just generate the .wasm Files can now be dragged to the virtual machine windows Uploading in ( install vmtools You can directly drag )

Copy after upload service url

Back to the flying book open platform , Click on Time subscription

Edit request URL , Copy just now service url copied

It should be noted that after copying the web address, you need to add /internal

Add event

4.5 Version release

Create a new version in version publishing and management

Version filling 1.0 that will do

Click save

Then apply for release

Waiting for approval

5 Install flybook application locally

5.1 Register and log in to flybook

With windows For example

Download link :https://www.feishu.cn/download

After downloading the installation package, you can install it by default

Log in after installation

Application main interface

Search for calculators in the search bar

You can see the application we created

5.2 Computer robot application experience

The experience was pretty good , Welcome to try !

原网站

版权声明
本文为[Brother tortoise]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/05/20210525190743114p.html