Cloudflare-worker-request-data 怎么获取传输数据

Cloudflare-worker-request-data

Cloudflare Workers 是一个serverless的运行环境。

在Cloudflare Worker中获取传输的GET或者POST数据,并不像在Nodejs的Express框架下那么的简单,你需要深入的了解cloudflare-worker的request变量的组成。

Cloudflare-worker-request-data 是一个免费的基于MIT license的npm package. 可以直接帮助你获取GET或者POST请求中包含的数据。这样就不用花很多事件去了解request变量的组成了。

安装

npm i cloudflare-worker-request-data

例子

1
2
3
4
5
6
7
8
import { RequestData } from 'cloudflare-worker-request-data';

export default {
async fetch(request, env, ctx) {
const data = await RequestData(request)
// do something with the data
}
};

说明

在上面的例子中,通过获取RequestData(request) ,可以得到如下的return

  • 字符串 , 如果content-type是 “application/text” or “text/html”
  • Object, 如果content-type是 “application/json”, “application/x-www-form-urlencoded”, “mutipart/form-data”
  • 空白字符串, 如果在GET POST请求里面并没有数据的话

请求的类型应当是 GET 或 POST, 其他类型的请求,你将会得到一个空白的字符串。

水厂污水厂设计计算软件TWSolutions,格栅设计计算

水厂污水厂设计计算软件TWSolutions,格栅设计计算

使用TWSolutions提供的给水厂和污水厂设计计算软件进行格栅设计计算的详细步骤如下:

启动软件并选择设计模块:

打开TWSolutions软件(通过浏览器打开网址)https://t.wtsolutions.cn/forms ,选择“污水厂设计”模块。
在模块中选择“格栅设计计算Geshan1”功能。
图1

输入基本设计参数:

最大设计流量(Q_max):输入污水处理厂的最大设计流量,单位为立方米每秒(m³/s)。例如,输入0.4 m³/s。
总变化系数(K):输入总变化系数,通常为1.39。
栅条间隙(b):输入栅条之间的间隙,单位为米(m)。例如,输入0.021 m。
栅前水深(h):输入栅前水深,单位为米(m)。例如,输入0.4 m。
过栅流速(v):输入污水通过格栅的流速,单位为米每秒(m/s)。例如,输入0.9 m/s。
栅条宽度(S):输入栅条的宽度,单位为米(m)。例如,输入0.01 m。
图2

选择默认参数(可选):

如果某些参数不确定,可以使用软件提供的默认参数。这些参数通常基于行业标准和设计手册。
或者,也可以点击在页面底端的按钮“设计计算有疑问,点击问AI”进行设计参数的提问。比如下图给了一个示例,用于通过与AI问答,获得格栅的栅条间隙参数。

图3

进行计算:

点击“开始计算”按钮,软件将根据输入的参数自动进行计算。
计算内容包括栅条间隙数(n)、栅槽宽度(B)、通过格栅的水头损失(h)等。

查看和验证计算结果:

软件会生成详细的计算书,显示各项计算结果。
验证计算结果是否符合设计要求。例如,栅槽宽度是否合理,水头损失是否在可接受范围内。

图4
图5

调整和优化设计:

如果计算结果不符合要求,可以调整输入参数并重新计算。
例如,调整栅条间隙或过栅流速,以优化设计。

参考规范和手册:

在计算过程中,可以参考相关的设计规范、手册或使用AI工具进行进一步的问题解答和参数确认。

生成设计报告:

完成计算后,可以生成设计报告,保存计算结果和设计参数。

通过以上详细步骤,您可以有效地使用TWSolutions软件进行污水厂格栅的设计计算。

Extracting rgba value of each pixel of an image

In this blog post, a free online webapp is recommended to extract rgba value of image pixels, and save as a csv file.

Tool

Image Pixel Rgba

Access

https://s.wtsolutions.cn/image-pixel-rgba.html

Usage

  1. Opening the link above
  2. Drag and drop your images to the webapp
  3. Wait until a pop up showing completion
  4. Check for the exported .csv file

Advantages

  1. Free Webapp
  2. Privacy matters, the images will stay locally on your device, will not be transmitted to any server.
  3. Very simple UI, simple to use.

Convert Excel to JSON within Excel

In this blog post, a free solution for converting Excel to JSON is presented.

Excel-to-JSON add-in

Excel to JSON is a Microsoft Excel add-in which can convert Excel to JSON.

Works with

  • Excel 2016 or higher, or
  • Office 365, or
  • Excel Online

Advantage

  • Free
  • No download
  • No installation
  • Load only when needed
  • Load within Excel
  • No need coding in Python/JavaScript (for example)

Excel-to-JSON add-in

How to load this add-in

  • Steps
  1. Go to Excel 2016, Office365 or Excel Online.
  2. Insert Tab > My Add-ins.
  3. In the popup window, go to Office Store
  4. Search “Excel-to-JSON”.
  5. Add this add-in
  6. After loading, go to the “Excel-to-JSON” tab.

Now you are ready to use this add-in.

How to use this add-in

Example

Example Excel sheet - Source

Name Age Company
David 27 WTSolutions
Ton 26 WTSolutions
Kitty 30 Microsoft
Linda 30 Microsoft
Joe 40 Github

Example JSON - Output

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[
{
"Name": "David",
"Age": 27,
"Company": "WTSolutions"
},
{
"Name": "Ton",
"Age": 26,
"Company": "WTSolutions"
},
{
"Name": "Kitty",
"Age": 30,
"Company": "Microsoft"
},
{
"Name": "Linda",
"Age": 30,
"Company": "Microsoft"
},
{
"Name": "Joe",
"Age": 40,
"Company": "Github"
}
]

How to get data from Cloudflare worker GET/POST requests

Cloudflare worker

Cloudflare Workers provides a serverless execution environment that allows you to create entirely new applications or augment existing ones without configuring or maintaining infrastructure.

Documentation for Cloudflare worker.

Cloudflare-worker-request-data

Getting data from Cloudflare-worker requests is not as easy as you were working with Express.js on Nodejs, it is necessary to understand the organization of request in Cloudflare-worker.

Cloudflare-worker-request-data is a JavaScript package released under MIT license, which can help you with getting data from a GET or POST request. With this package, it is not necessary to study the API of request from documentation file, and the usage is quite simple and straightforward.

Installation

1
npm i cloudflare-worker-request-data

Example

1
2
3
4
5
6
7
8
9
10
11
import { RequestData } from 'cloudflare-worker-request-data';

export default {
async fetch(request, env, ctx) {

const data = await RequestData(request)

// do something with the data

}
};

Description

RequestData(request) in the above example can get return of

  • a String in case of “application/text” or “text/html”
  • a Object in case of “application/json”, “application/x-www-form-urlencoded”, “mutipart/form-data”
  • a String which is empty if nothing parsed
  • The request shall be either in GET or POST, other methods of request will directly return you with an empty String.