切换为 goja
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>qjs 验证</title>
|
||||
<title>js 验证</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Hello World</p>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
routes:
|
||||
- path: "api/dev/**"
|
||||
qjs:
|
||||
js:
|
||||
exec: "index.js"
|
||||
debug: true
|
||||
- path: "api/prod/**"
|
||||
qjs:
|
||||
js:
|
||||
exec: "json.js"
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Quickjs 概念验证</title>
|
||||
<title>JS 概念验证</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
response.write("hello world")
|
||||
console.log("hello world")
|
||||
console.log(req.methaaod)
|
||||
function testError(){
|
||||
throw Error("Method not implemented")
|
||||
}
|
||||
response.setHeader("content-type", "application/json")
|
||||
testError()
|
||||
10
examples/kv/.pages.yaml
Normal file
10
examples/kv/.pages.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
routes:
|
||||
- path: "get"
|
||||
js:
|
||||
exec: "index.js"
|
||||
debug: true
|
||||
|
||||
- path: "put"
|
||||
js:
|
||||
exec: "index.js"
|
||||
debug: true
|
||||
14
examples/kv/index.html
Normal file
14
examples/kv/index.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>JS 概念验证</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="/get">查询数据</a>
|
||||
<a href="/put">更新数据</a>
|
||||
</body>
|
||||
</html>
|
||||
10
examples/kv/index.js
Normal file
10
examples/kv/index.js
Normal file
@@ -0,0 +1,10 @@
|
||||
var db = kv.repo("self");
|
||||
if(request.path == "put"){
|
||||
data = db.get('key')
|
||||
if(data == undefined){
|
||||
db.set('key','0')
|
||||
}else {
|
||||
db.set('key',(parseInt(data)+1).toString())
|
||||
}
|
||||
}
|
||||
response.write("当前存储的数值为 " + db.get('key'))
|
||||
Reference in New Issue
Block a user