In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to achieve Flask installation in python, which is very detailed and has certain reference value. Friends who are interested must finish it!
Flask is a lightweight Web application framework that handles users' http requests and returns the results to specific pages to be displayed on the client side.
Linux and mac os x systems install flask with the following command:
Sudo-H python3-m pip install flask
For Windows systems, type in the cmd command prompt:
Py-3-m pip install flask
After waiting for a while, the following prompt appears and the installation is successful:
After the installation is complete, let's write a simple program to try and create a new file hello_flask.py.
From flask import Flask
App = Flask (_ _ name__)
@ app.route ('/')
Def hello ()-> str:
Return'my first flask program'
App.run ()
From flask import Flask
We imported the Flask class. An instance of this class will be our WSGI application, WSGI: Web Server Gateway Interface, the Web server gateway interface
Is the standard developed by python web, it is a contract between server program and application program, which specifies the interface and function that they use, so that the two programs can cooperate with each other. Flask implements the WSGI interface, which greatly simplifies the process of web development.
App = Flask (_ _ name__)
Let's create an instance of this class. The first parameter is the name of the application module or package. Here, use _ _ name__.
@ app.route ('/')
Route, which defines the path of the URL.'/ 'represents the root directory, which can be accessed by 127.0.0.1 VOL5000.
Def hello ()-> str:
Return'my first flask program'
Define the hello () method and return the string'my first flask program'
App.run ()
Run the flask program
Run the cmd command in the current directory and enter:
Py hello_flask.py
The prompt program runs on port 5000 of this machine.
Open 127.0.0.1 flask 5000 with a browser and return the data "my first Java program".
Congratulations, Flask has been installed and run successfully.
The above is all the contents of the article "how to implement Flask installation in python". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.