Adrian Gropper
Adrian Gropper

Reputation: 11

How to run a Flask app for App Platform locally in my venv?

I have a simple Flask app that runs on DigitalOcean App Platform with the run command: gunicorn --worker-tmp-dir /dev/shm --config gunicorn_config.py app:app

I would like to test this locally in my virtual environment before pushing it to GitHub. What is the proper way to start the app locally with a python command (without messing up the way it runs on App Platform)?

Upvotes: 1

Views: 5609

Answers (2)

Austin Heywood
Austin Heywood

Reputation: 1

here you go, i setup a flask postgres starter project for digital ocean app platform:

https://github.com/heyaustinwood/flask-do-app-platform

You can set it up and then run it locally first before you setup the project in digital ocean by following the steps in the readme

Upvotes: 0

sigalgleb
sigalgleb

Reputation: 208

  1. Create venv:

    python -m venv venv

  2. Activate venv:

    source venv/bin/activate

  3. Install Flask:

    pip install flask

  4. Create flask app in main.py (or use your own)

    from flask import Flask
    
    app = Flask(__name__)
    
    @app.route("/")
    def hello_world():
       return "<p>Hello, World!</p>"
    
  5. Run your app:

    set FLASK_APP=main # write your script name (my is main.py)
    flask run # * Running on http://127.0.0.1:5000/
    
  6. Open your browser on http://127.0.0.1:5000/

More information in official documentation

Upvotes: 1

Related Questions