Skip to main content

Command Palette

Search for a command to run...

[TIL] Two Flask Toy Projects & AWS Deployment

03/03/2023

Updated
[TIL] Two Flask Toy Projects & AWS Deployment

Today, I learned how to use Flask to build a toy project for the back-end and deploy it on AWS. Through implementing two projects on my own, I gained a better understanding of the workflow and the communication between the back-end and front-end.


Toy Project 1: Bucket List Page

  • Webpage Workflow

    • Users can write their bucket lists and submit it

    • Submitted input will be saved in MongoDB

    • All items stored in MongoDB will be listed on the page

    • Users can mark each list as completed

Toy Project 2: NewJeans Fan Page

  • Webpage Workflow

    • Users can write their nickname and comment and submit it

    • Submitted input will be saved in MongoDB

    • All items stored in MongoDB will be listed on the page

  • OG Tag

      <meta property="og:title" content="NewJeans Fan Book" />
      <meta property="og:description" content="Support your artist!" />
      <meta property="og:image" content="http://res.heraldm.com/content/image/2022/12/19/20221219000702_0.jpg" />
    
  • Directory Info

AWS Deployment

  • How to deploy (by using AWS Elastic Beanstalk Environments)

    1. Save your Access Key & Secret Access Key (under Secret Credential)

    2. Follow all steps below

      1. Prepare Terminal

        1. mkdir deploy

        2. cp app.py deploy/application.py

        3. cp -r templates deploy/templates

        4. pip freeze > deploy/requirements.txt

        5. cd deploy

      2. Modify deploy/application.py

         1) app = Flask(__name__) => application = app = Flask(__name__)
        
         2) 
         if __name__ == '__main__':
            app.run('0.0.0.0', port=5000, debug=True) => app.run()
        
      3. Install package: pip install awsebcli

      4. Security Credentials: eb init

      5. Initial Setting eb create myweb

    3. Click the URL created on the AWS website

  • How to modify after deployment

    1. Make changes on files connected to localhost first to make sure it works properly on the local environment

    2. Apply changes to files under deploy folder

    3. Move to the deploy folder through cd deploy

    4. Enter eb deploy myweb for updates

Today I Learned

Part 1 of 50

Today I Learned!