Git Product home page Git Product logo

pastebin-clone's Introduction

Pybin - Pastebin Clone

Python Flask MongoDB Docker

Pytest Coverage Status

✨ Features

  • OAuth Authentication
  • Email Verification
  • Syntax Highlighting
  • Search Pastes
  • Paste Commenting and Rating
  • Public and Private Paste Creation
  • Welcoming Message on User Signup

🔍 Preview

Preview

📖 Instructions

1. Clone this repository onto your local machine, cd into it

git clone [email protected]:hatredholder/Pastebin-Clone.git
cd Pastebin-Clone

2. Update enviroment variables in .env to match your preferences

# Flask Settings
FLASK_SECRET_KEY="your_secret_key_here"
FLASK_EMAIL_VERIFICATION_ENABLED=false
FLASK_SOCIAL_AUTHENTICATION_ENABLED=false

# Mongo Settings
FLASK_MONGODB_SETTINGS={"db": "pastebinCloneDb", "host": "db", "port": 27017}
To Enable Email Verification

  • Set FLASK_EMAIL_VERIFICATION_ENABLED to true

    FLASK_EMAIL_VERIFICATION_ENABLED=true
    

  • Set these enviroment variables to your email credentials

    FLASK_MAIL_SERVER="smtp.gmail.com"
    FLASK_MAIL_USERNAME="[email protected]"
    FLASK_MAIL_PASSWORD="example_password"
    FLASK_MAIL_PORT=587
    FLASK_MAIL_USE_TLS=true
    FLASK_MAIL_USE_SSL=false
    

    NOTE: In order for GMail to work as your email server you need to setup two-factor authorization (2FA)

To Enable OAuth Authentication

  • Set FLASK_EMAIL_VERIFICATION_ENABLED to true

    FLASK_SOCIAL_AUTHENTICATION_ENABLED=true
    

  • Create a new project in Google Cloud

  • Go to https://console.cloud.google.com/
  • Register a service with Google > create a new project
  • Within the new project, go to APIs + Services > Create credentials > Configure Consent Screen > External Users > name the project again > enter user support email > leave defaults
  • Go back to dashboard > Credentials > Create Creds > OAuth Client ID > web app > define your redirect url of your web app (http://localhost/login/callback)
  • Create the call back > download your creds as a json file
  • Put the client_secret.json file to your source directory (next to app.py)

Your project filetree should look like this

├── authentication/
├── pybin/
├── requirements/
├── static/
├── templates/
├── tests/
├── .env
├── .gitignore
├── Dockerfile
├── README.md
├── app.py
├── client_secret.json
├── docker-compose.yml
└── setup.cfg

3. Run the server with docker-compose

docker-compose up -d

🧪 Testing

1. To use the tests you need to install local module requirements first, to do that, use:

pip install -r requirements/local.txt

2. Run the tests and check the coverage:

pytest -k "not email_configured and not oauth_configured" --cov

3. Generate an HTML coverage report:

pytest -k "not email_configured and not oauth_configured" --cov-report html:cov_html --cov

4. Test the code quality (see if there are any PEP8 errors):

ruff --check .

pastebin-clone's People

Contributors

hatredholder avatar

Stargazers

 avatar  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.