PrimitiveSource
PrimitiveSource

Reputation: 209

Start flask with venv using a .bat file

I am trying to start a flask application using a .bat file but Iam having a few issues. The cmd seems to get to the line "env\Scripts\activate" then shuts down the cmd window. If I run each line individually in cmd then my application starts fine.

I want to automate it so I don't have input each line to start my application.

I am new to flask in the windows environment and .bat files.

I have tried changing the set lines to $env: but i still get the same problem.

cd C:\Users\admin\Documents\Flask
py -m venv env
env\Scripts\activate
set FLASK_APP=TrialPage.py
set FLASK_ENV=development
flask run --host=0.0.0.0

I would like my flask app to run automatically after executing the .bat file.

Upvotes: 3

Views: 7878

Answers (1)

PrimitiveSource
PrimitiveSource

Reputation: 209

Solved it, venv is creating a batch file which i need to run by using the CALL command as found in this post.

How do I run a batch script from within a batch script?

changing my .bat code to the following worked.

cd C:\Users\admin\Documents\Flask
py -m venv env
CALL env\Scripts\activate
set FLASK_APP=TrialPage.py
set FLASK_ENV=development
flask run --host=0.0.0.0

Upvotes: 9

Related Questions