conda and flask not logging anything

Question:

I just started with python and am confused that my code does not behave the way the examples show.

from flask import Flask
app = Flask(__name__)

@app.route('/')
def index():
  return 'Server Works!'
  
@app.route('/greet')
def say_hello():
  return 'Hello from Server'

conda run -n myenv flask run

after this command, nothing appears, yet the app works.

Using VSCODE and Windows 10 Terminal

Asked By: TMvytKA9LgSVZ8Z7

||

Answers:

The reason you don’t see anything in the console is because conda run capture your output.

If you want to run the above command with conda run, you need to use the folowing command

conda run --no-capture-output  flask run

But I think you shouldn’t run command like that. Activate the environment first and do anything in activated shell.

conda activate -n myenv
flask run
Answered By: thangdc94
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.