python flask
时间: 2023-09-02 14:09:04 浏览: 86
Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions. However, Flask supports extensions that can add application features as if they were implemented in Flask itself. Extensions exist for object-relational mappers, form validation, upload handling, various open authentication technologies and several common framework-related tools.
Flask is based on the Werkzeug WSGI toolkit and Jinja2 template engine. Both are Pocco projects. Flask is also called a "micro framework" because it can be used to create web applications with very little code. Flask is easy to get started with and is very flexible. It is a good choice for small to medium-sized websites and web applications, RESTful services, and APIs.
Here is an example of a simple Flask app that returns "Hello World!" when the root URL is requested:
```
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
```
This code creates a Flask application instance and defines a route (the root URL '/'). When the route is accessed, the `hello_world()` function is called and returns the message "Hello World!". Finally, the application is run using the `run()` method.
阅读全文
相关推荐














