Coder Social home page Coder Social logo

ymind / linklet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from harrisonwang/linklet

0.0 0.0 0.0 29 KB

一个使用 Cloudflare Pages 创建的 URL 缩短器。A URL Shortener created using Cloudflare Pages

Home Page: https://t.xiaowangye.org

License: MIT License

JavaScript 54.92% HTML 45.08%

linklet's Introduction

介绍

一个使用 Cloudflare Pages 创建的 URL 缩短器

演示站点 : t.xiaowangye.org, linklet.pages.dev

1.利用 Cloudflare Pages 部署

  1. Fork linklet 仓库
  2. 登录到 Cloudflare 控制台。
  3. 在 Cloudflare 控制台,选择 Workers & Pages > Create application > Pages > Connect to Git
  4. 选择 Fork 的仓库,若没有该仓库,请点击 Cloudflare Pages 链接配置 Cloudflare 访问个人的 GitHub 仓库权限。
  5. 选中 Fork 的仓库,点击Begin setup完成部署。
  6. 在 Cloudflare 控制台创建 D1 数据库,依次点击 Workers & Pages > D1 > Create database > Dashboard,输入 Database name 点击 Create 完成数据库的创建。
  7. 点击 Console,输入以下 SQL 命令创建表:
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
);
  1. 选择部署完成的 linklet 项目,在 Cloudflare 控制台依次点击Settings > Functions > Add bindings,输入 Variable name 值 DB 并选择 D1 Database linklet,点击 Save 保存,设置如下表:

    Variable name D1 database
    DB linklet
  2. 为了生效 D1 数据库配置,需完成项目的重新部署。

2.API 方式生成短网址

请求:

### 生成随机短链接
POST https://wss.so/create
Content-Type: application/json

{
  "url": "https://ollama.com/blog/how-to-prompt-code-llama"
}

### 生成指定 slug 短链接
POST https://wss.so/create
Content-Type: application/json

{
  "url": "https://ollama.com/blog/how-to-prompt-code-llama",
  "slug": "llama"
}

响应:

{
  "slug": "<slug>",
  "link": "http://wss.so/<slug>"
}

linklet's People

Contributors

x-dr avatar harrisonwang avatar ymind avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.