项目作者: hlong24399

项目描述 :
Using Flask, Sqlalchemy, Auth-lib, Flask-Dance and Flask-Sqlalchemy to create url shortener web app.
高级语言: Python
项目地址: git://github.com/hlong24399/Url-Shortener.git
创建时间: 2020-12-31T06:08:02Z
项目社区:https://github.com/hlong24399/Url-Shortener

开源协议:

下载


URL Shortener

  • Simple API that will generate encrypted Short Url.

  • This API utilizes Flask and Flask-SQLAlchemy framework. User input will be stored in short-url database.

  • For easy use, click and flask-cli are integrated to make terminal command to create the data table.

  • Auth-lib is integrated to authorize user login with Google OAuth2 authentication.

Install requirement

It is highly recommended to work in venv- python virtual environment to avoid any collisions with your machine’s python configuration

Execute the command below to install requirement packages:

pip3 install -r requirements.txt

Configuration

  • You need to obtain OAuth 2.0 client credentials from the Google API Console Platform first to be able to run the authentication.

  • Obtain the google cloud oauth 2.0 client id and secret since we need those to fill out .env.

  • dotenv is used to work with environment variable, .env file must be created in app/.

  • .env file should look like:
  1. FLASK_APP=app
  2. FLASK_SECRET_KEY=<secretkey>
  3. FLASK_ENV=development
  4. OAUTHLIB_INSECURE_TRANSPORT=true
  5. OAUTHLIB_RELAX_TOKEN_SCOPE=true
  6. GOOGLE_CLIENT_ID=<client id generated by google cloud oauth 2.0 service>
  7. GOOGLE_CLIENT_SECRET=<secret generated by google cloud oauth 2.0 service>
  8. DATABASE_URL=sqlite:///short-url.sqlite3

Execution

  1. Create the database

flask create_db

  1. Run the app

flask run

Demo

image
image
image
image
image