GithubHelp home page GithubHelp logo

u13's Introduction

u13 url shortener

Simple URL shortener

Run the server locally

$ flask run --reload
 * Serving Flask app 'u13'
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
Press CTRL+C to quit
 * Restarting with stat

Creating users for the stats page

Create an admin user with password admin123:

echo "admin:admin:$(python -c 'from werkzeug.security import generate_password_hash; print(generate_password_hash("admin123"))')" >> instance/users.txt

This assumes the instance directory already exists, it will be auto-created when the server is running

Add a link and access it

$ http POST http://localhost:5000/short/add_link url='https://github.com/martineg/u13'
HTTP/1.1 200 OK
Connection: close
Content-Length: 64
Content-Type: application/json
Date: Fri, 07 Jun 2024 13:33:25 GMT
Server: Werkzeug/3.0.3 Python/3.12.3

{
    "short_url": "3610ba2",
    "url": "https://github.com/martineg/u13"
}

$ http GET http://localhost:5000/short/3610ba2
HTTP/1.1 302 FOUND
Connection: close
Content-Length: 249
Content-Type: text/html; charset=utf-8
Date: Fri, 07 Jun 2024 13:34:26 GMT
Location: https://github.com/martineg/u13
Server: Werkzeug/3.0.3 Python/3.12.3

<!doctype html>
<html lang=en>
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to the target URL: <a href="https://github.com/martineg/u13">https://github.com/martineg/u13</a>. If not, click the link.

Show statistics

$ http GET http://localhost:5000/short/stats --auth admin:admin123
HTTP/1.1 200 OK
Connection: close
Content-Length: 48
Content-Type: application/json
Date: Fri, 07 Jun 2024 13:35:47 GMT
Server: Werkzeug/3.0.3 Python/3.12.3

{
    "stats": {
        "https://github.com/martineg/u13": 3
    }
}

u13's People

Contributors

martineg avatar

Watchers

 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.