pages
> Create a project
> Connect to Git
Set up builds and deployments
部分中,全部默认即可。Save and Deploy
,稍等片刻,你的网站就部署好了。DROP TABLE IF EXISTS links;
CREATE TABLE IF NOT EXISTS links (
`id` integer PRIMARY KEY NOT NULL,
`url` text,
`slug` text,
`ua` text,
`ip` text,
`status` int,
`create_time` DATE
);
DROP TABLE IF EXISTS logs;
CREATE TABLE IF NOT EXISTS logs (
`id` integer PRIMARY KEY NOT NULL,
`url` text ,
`slug` text,
`referer` text,
`ua` text ,
`ip` text ,
`create_time` DATE
);
设置
->函数
->D1 数据库绑定
->编辑绑定
->变量名称填写:DB
命名空间 选择你提前创建好的D1
数据库绑定# POST /create
curl -X POST -H "Content-Type: application/json" -d '{"url":"https://131213.xyz"}' https://d.131213.xyz/create
# 指定slug
curl -X POST -H "Content-Type: application/json" -d '{"url":"https://131213.xyz","slug":"scxs"}' https://d.131213.xyz/create
response:
{
"slug": "<slug>",
"link": "http://d.131213.xyz/<slug>"
}