Skip to content

Instantly share code, notes, and snippets.

@leongjinqwen
leongjinqwen / heroku-deployment.md
Created November 13, 2020 12:08
Step by step deploy your app to Heroku

Heroku Deployment

  1. Create an app on Heroku
  2. Create a free Postgres Heroku instance.
  3. Set a new git remote to your Heroku git link
  4. Copy your Heroku git link from Heroku's website
  5. Go back to the root of your project directory and type
git remote add production <your heroku git link>
@leongjinqwen
leongjinqwen / django-orm.md
Last active January 1, 2024 07:06
Integrate flask with django orm
@leongjinqwen
leongjinqwen / upload-to-aws-flask.md
Created January 23, 2020 15:32
upload files to aws s3 bucket with flask

Upload files to AWS

Make sure you already have S3 bucket, access key and secret key before go through this notes.

How to connect to AWS?

Boto3 allows Python developers to write software that makes use of services like Amazon S3 and Amazon EC2.

Step 1: Install boto3 with pip

pip install boto3
@leongjinqwen
leongjinqwen / flask-blueprint.md
Created January 21, 2020 11:26
summary on how flask-blueprint works

Flask Blueprint

Documentation: https://flask.palletsprojects.com/en/1.0.x/blueprints/

A Blueprint object works similarly to a Flask application object, but it is not actually an application. Rather it is a blueprint of how to construct or extend an application.

Defining a Blueprint

# instagram_web/blueprints/users/views.py

from flask import Blueprint
@leongjinqwen
leongjinqwen / flask-login.md
Last active June 25, 2024 08:37
Summary on how to use flask-login

How to use Flask-Login in Flask?

  1. Make sure you have SECRET_KEY in your .env file
    • Flask-Login uses sessions for authentication, secret key is used to encrypting the cookies in session, the user could look at the contents of cookie but not modify it, unless they know the secret key used for signing.
  2. Initializing Flask-Login in your app.py or __init__.py
    • A user loader tells Flask-Login how to get a specific user object from the ID that is stored in the session cookie
      from flask_login import LoginManager
      from models.user import User

login_manager = LoginManager()