Skip to content

ShortURL is the server-side of a simple url-shortener, written in C#

License

Notifications You must be signed in to change notification settings

Gaojianli/UrlShorter

Repository files navigation

Welcome to UrlShorter 👋

Version License: MIT FOSSA: Scan

ShortURL is a open source URL shortening service (a.k.a URL redirection) allowing anyone to take any existing URL and shorten it.

Config

Name Type Details
SqlConnection string The connection string of the database
origin string The origin of the web ui, usually is just the URL of the web. If you set this uncorrectly, you may meet CORS error.
homePage string The URL of the web, if one short url is missing, the user will be redirected here.
prefix string The prefix of each short url.

Here're the config running on https://short.u2b.eu:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "SqlConnection": "server=localhost;port=3306;database=shortUrl;uid=shorturl;pwd=<pwd>;CharSet=utf8"
  },
  "SiteSettings": {
    "origin": "https://short.u2b.eu",
    "homePage": "https://short.u2b.eu",
    "prefix": "https://u2b.eu"
  },
  "Kestrel": {
    "EndPoints": {
      "Http": {
        "Url": "http://0.0.0.0:5000"
      }
    }
  }
}

Install

Docker(Recommended)

  1. Import the init.sql into your Mysql/Mariadb
  2. Run the container
docker run -d -e ConnectionStrings__SqlConnection="server=<ip to the db>;port=<db port>;database=shortUrl;uid=shorturl;pwd=<pwd>;CharSet=utf8" \
-e SiteSettings__origin="https://short.u2b.eu" \
-e SiteSettings__homePage="https://short.u2b.eu" \
-e SiteSettings__prefix="https://u2b.eu" \
-p 5000:5000 \
--name url_shorter \
--restart=always \
url_shorter

Manually

  1. Import the init.sql into your Mysql/Mariadb
  2. Edit your database config in appsettings.json, then run:
dotnet build

Usage

dotnet run

Author

👤 Gaojianli

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2020 Gaojianli.
This project is MIT licensed.

FOSSA Status


This README was generated with ❤️ by readme-md-generator

About

ShortURL is the server-side of a simple url-shortener, written in C#

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published