Giter Club home page Giter Club logo

serverless-flask-webapp-with-s3's Introduction

Serverless Flask WebApp with S3

Serverless Flask WebApp with S3(for static content like images,css,js etc).

Installation

git clone https://github.com/vabhishek-me/serverless-flask-webapp-with-s3.git;
cd serverless-flask-webapp-with-s3;
  • Install virtualenv on your system to create a virtual environment.

    pip3 install virtualenv;
  • Create a virtualenv named flaskenv and activate it.

    virtualenv -p python3.6 flaskenv;
    source flaskenv/bin/activate;
  • Install all the dependencies.

    pip install -r requirements.txt
  • To run the project locally:

    python app.local.py
    
    # Open localhost:5000

Directory Structure

.
├── static              # Contains static files like images,css,js,videos etc. - will be pushed to s3 eventually
├── template            # Contains all the templates - use `{{ url_for('static', filename='path/to/file') }}` for s3 links to work
├── app.py              # Contains all the routing stuffs
├── app.local.py        # To run project locally before deployment
├── upload-to-s3.py     # Python script to upload content from static folder to s3 bucket - run it before deployment
├── requirements.txt    # Python packages list - to recreate when new packages are installed, do "pip freeze > requirements.txt"

Deploying

  1. Add all your api-endpoints, static files and templates.

  2. Run upload-to-s3.py script to upload all your static files to s3.

  python3 upload-to-s3.py
  1. Install ZAPPA. If you ran pip install -r requirements.txt before, you should have zappa installed. Otherwise, install using pip install zappa

  2. Run zappa init and provide the values as required for the configuration.

  3. Once configured, you'll see a zappa_settings.json file.

  4. Now, run zappa deploy to deploy your website. After successful deployment, You'll get an endpoint which you can use to visit your website.

Yayyy! Your site is live.

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.