0

What happened after entered "flask run" on a terminal under the project directory? How the python interpreter gets the file of flask.__main__.py and starts running project's code?

I know how Flask locates app. What I want to figure out is how command line instruction "flask run" get the flask/__main__.py bootup

polar9527
  • 488
  • 4
  • 18
  • You can look at [the code](https://github.com/pallets/flask/blob/c5c8bbc7f699de6b81ebd9893dc0a2289ae688dc/flask/cli.py#L364) yourself to see the logic how Flask locates app. – Tomáš Linhart Apr 16 '19 at 11:49
  • 1
    I know how Flask locates app. What I want to figure out is how command line instruction "flask run" get the flask/__main__.py launch – polar9527 Apr 16 '19 at 12:46

2 Answers2

2

flask is a Python script. Since you stated you are not a beginner, you should simply open the file (/usr/bin/flask) in your favorite text editor and start from there. There is no magic under the hood.

sleblanc
  • 3,821
  • 1
  • 34
  • 42
0

To run the application you can either use the flask command or python’s -m switch with Flask. Before you can do that you need to tell your terminal the application to work with by exporting the FLASK_APP environment variable:

Imp - This launches a very simple builtin server.

Please read it :- http://flask.pocoo.org/docs/0.12/quickstart/

Yash Shukla
  • 141
  • 6