All Projects → highoncarbs → Shorty

highoncarbs / Shorty

Licence: mit
🔗 A URL shortening service built using Flask and MySQL

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Shorty

Uwsgi Nginx Flask Docker
Docker image with uWSGI and Nginx for Flask applications in Python running in a single container. Optionally with Alpine Linux.
Stars: ✭ 2,607 (+3242.31%)
Mutual labels:  flask, uwsgi, nginx, webapp
Docker Nginx Gunicorn Flask Letsencrypt
Boilerplate code for setting up Nginx + Gunicorn + Flask + automated LetsEncrypt certificates (https) using docker-compose.
Stars: ✭ 117 (+50%)
Mutual labels:  flask, nginx, webapp
Flask Restful Authentication
An example for RESTful authentication using nginx, uWSGI, Flask, MongoDB and JSON Web Token(JWT).
Stars: ✭ 63 (-19.23%)
Mutual labels:  flask, uwsgi, nginx
Laconia
🏺 ‎ A minimalist MVC framework.
Stars: ✭ 307 (+293.59%)
Mutual labels:  database, mysql, webapp
Pyblog
Pyblog 是一个简单易用的在线 Markdown 博客系统,它使用 Python 的 flask 架构,理论上支持所有 flask-sqlalchemy 所能支持的数据库。 编辑器使用的是 editor.md。当前版本(v2.0)支持且仅支持 python3! Python 的 Markdown to HTML 编译器使用的是 Mistune! Just so!
Stars: ✭ 113 (+44.87%)
Mutual labels:  flask, uwsgi, nginx
Pygmy
An open-source, feature rich & extensible url-shortener + analytics written in Python 🍪
Stars: ✭ 569 (+629.49%)
Mutual labels:  url-shortener, analytics, flask
Owasp Mth3l3m3nt Framework
OWASP Mth3l3m3nt Framework is a penetration testing aiding tool and exploitation framework. It fosters a principle of attack the web using the web as well as pentest on the go through its responsive interface.
Stars: ✭ 139 (+78.21%)
Mutual labels:  database, mysql, nginx
Autoops
linux资产管理,cmdb,django, webssh,运维管理平台,数据库操作平台 本项目已停止开发!因长时间未对代码进行维护,可能会造成项目在不同环境上无法部署、运行BUG等问题,请知晓!项目仅供参考!
Stars: ✭ 340 (+335.9%)
Mutual labels:  mysql, uwsgi, nginx
Opman Django
💯✅自动化运维平台:CMDB、CI/CD、DevOps、资产管理、任务编排、持续交付、系统监控、运维管理、配置管理
Stars: ✭ 539 (+591.03%)
Mutual labels:  mysql, uwsgi, nginx
Uwsgi Nginx Docker
Docker image with uWSGI and Nginx for applications in Python 3.5 and above and Python 2.7 (as Flask) in a single container. Optionally with Alpine Linux.
Stars: ✭ 466 (+497.44%)
Mutual labels:  uwsgi, nginx, webapp
Botvid 19
Messenger Bot that scrapes for COVID-19 data and periodically updates subscribers via Facebook Messages. Created using Python/Flask, MYSQL, HTML, Heroku
Stars: ✭ 34 (-56.41%)
Mutual labels:  mysql, flask, webapp
Metabase
The simplest, fastest way to get business intelligence and analytics to everyone in your company 😋
Stars: ✭ 26,803 (+34262.82%)
Mutual labels:  analytics, database, mysql
Data Science Best Resources
Carefully curated resource links for data science in one place
Stars: ✭ 1,104 (+1315.38%)
Mutual labels:  aws, analytics, database
Scalikejdbc
A tidy SQL-based DB access library for Scala developers. This library naturally wraps JDBC APIs and provides you easy-to-use APIs.
Stars: ✭ 1,139 (+1360.26%)
Mutual labels:  database, mysql
Event Management
helps to register an users for on events conducted in college fests with simple logic with secured way
Stars: ✭ 65 (-16.67%)
Mutual labels:  database, mysql
Docker Examples
There are many like it, but this one is mine.
Stars: ✭ 66 (-15.38%)
Mutual labels:  mysql, flask
Dbmigrations
A library for the creation, management, and installation of schema updates for relational databases.
Stars: ✭ 67 (-14.1%)
Mutual labels:  database, mysql
Backup
MySQL Database backup package for Laravel
Stars: ✭ 66 (-15.38%)
Mutual labels:  database, mysql
Etl with python
ETL with Python - Taught at DWH course 2017 (TAU)
Stars: ✭ 68 (-12.82%)
Mutual labels:  database, mysql
Zabbixdba
Zabbix Database Monitoring Service (Oracle, Pg, MySQL, MS SQL, DB2, etc.)
Stars: ✭ 68 (-12.82%)
Mutual labels:  database, mysql

🔗 Shorty

A self-hosted URL shortening service built using Flask & Mysql.

Demo image of Shorty

🎉 Surprise : Click Analytics

Tracking for Operating system and platform used to access the link is available.

Demo image for analytics

Getting Started

Clone or download this repository.

git clone https://github.com/PadamSethia/shorty.git

cd shorty/

python ./app.py

Prerequisites

This project requires Flask and MySQL . And MySQLdb python module for connection. You can install it using the following commands .

pip install flask

For mysql as backend

sudo apt install mysql-server

sudo apt-get install libmysqlclient-dev

pip install MySQL-python

Now run the following command to create the MySQL table

python ./create_table.py

Configure the MySQL database credentials in config.py Set the host , user , password and database name for MySQL connection.

Also under MySQL shell set

set autocommit = 0

This takes care of the concurrency issue.

RESTful API

POST /api/v1/shorten with form data url=https://github.com/PadamSethia , custom=blah & tag=test custom and tag are optional.

{
    "custom": "blah",
    "long_url": "https://github.com/PadamSethia",
    "short_url": "http://localhost:5454/blah",
    "tag": "test" 
}

GET /api/v1/expand/ with form data custom=blah

{
    "click_browser": {
        "CHROME": 0,
        "FIREFOX": 0,
        "OTHER_BROWSER": 0,
        "SAFARI": 0
    },
    "click_platform": {
        "ANDROID": 0,
        "IOS": 0,
        "LINUX": 0,
        "MAC": 0,
        "OTHER_PLATFORM": 0,
        "WINDOWS": 0
    },
    "clicks": 0,
    "custom": "blah",
    "long_url": "http://github.com/PadamSethia",
    "tag" : "test"
}

for now the web app and api run on different ports. app : 5000 , api : 8000

Running for production

This section outlines how to setup and run shorty on web servers. In this case I'll consider AWS EC2 instance.

  • Set up the EC2 instance.

...Learn more

  • Clone this git repository.

Change the Host in app.run() to 0.0.0.0 , for both shorty_api.py and app.py

Now if you run python ./app.py , shorty should run under the server IP as <server host>:<port> By default the port is 5000 , make sure to open the port before running the app.

Creating Script for running the app

The inbuilt flask server is not built for production , it might do down after a couple of days . So we need to use production ready web servers , for this we'll use uWSGI and Nginx.

First install uwsgi and nginx on EC2 instance

pip install uwsgi

If it doesn't work install from distro repo

For Ubuntu

sudo apt-get install uwsgi-core uwsgi-plugin-python & nginx

For CentOS / Amazon Linux

sudo yum install uwsgi & nginx

Using uWSGI to run app.py and shorty_api.py

The uwsgi file is already setup in this repo , just change the to your user name . For eg ,

wsgi-file = /home/<user>/shorty/app.py

Just change the <user> to your sepecified user name , for me it would be

wsgi-file = /home/padam/shorty/app.py

So update the uwsgi_app and uwsgi_api files.

Now to run the script , run

uwsgi --ini uwsgi_app &

The & is used to run app.py in background.

For the API run

uwsgi --ini uwsgi_api &

Both the processes will run in background .

Projects Used

License

This project is licensed under the MIT Licene.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].