1
votes

First of all I love you all.

So I am developing a little website using FLASK. And so everytime I start working on it I need to input these commands to cmd:

cd myproject
venv\scripts\activate
set FLASK_APP=project
set FLASK_ENV=development
flask run --host=0.0.0.0

Is there any way you lovely people could spare me the extra minute to input these commands to cmd. I mean is there a way to make a Batch File that I would call: start_server that would execute these commands.

Thank youuu!!

2
Google search “docker” and “docker-compose” with flask. I think this is what you need without having to create a virtual env. Here is an example: dev.to/alissonzampietro/… - Markonick

2 Answers

0
votes

I think something like this could help you. Open notepad and write the following:

@ECHO OFF
CALL venv\scripts\activate
set FLASK_APP=project
set FLASK_ENV=development
flask run --host=0.0.0.0

Save this as run.bat inside your myproject directory. Then you can call this new script.

0
votes

The following code may help you:

create init.py in your app folder (project):

from flask import Flask

def create_app():
    app = Flask(__name__)
    # configure the app here

    return app

then create run.py

from project import create_app

app = create_app()
if __name__ == "__main__":
    app.run(host="0.0.0.0", port="5000", debug=True, use_reloader=True)

then all you have to do is type python run.py an there you go. (make sure you're in virtual environment)