![]() ![]() The default port value is 5000 and you can set the parameter portto use the port number of your choice.īlueprints allow us to separate various endpoints into subdomains. ![]() This ensures that the server will be reachable from all addresses. The default value for host is localhost or 127.0.0.1Ġ.0.0.0 means “all IPv4 addresses on the local machine”. Host specifies the server on which we want our flask application to run. This line ensures that our Flask app runs only when it is executed in the main file and not when it is imported in some other fileĪpp.run(host='0.0.0.0', port=105) → Run the Flask application If _name_ = '_main_' → _name_ is a special variable in Python which takes the value of the script name. methods specify which HTTP methods are allowed. Now, let’s understand the working of the code line-by-line:įrom flask import Flask → Import the Flask classĪpp = Flask(_name_) → Create an instance of the methods=) → We use the route() decorator to tell Flask what URL should trigger the function. Launch any web browser and go to to see the app in action. ![]() You should see something like this: * Running on (Press CTRL+C to quit) Save this file as app.py (or any other filename you want) and go to terminal and type python app.py (i.e. Minimal Flask App from flask import Flask app = Flask(_name_) methods=) def welcome(): return "Hello World!" if _name_ = '_main_': app.run(host='0.0.0.0', port=105) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |