Flask Documentation (1.1.x)and Decoding Yourself Configuring Editors Flask Extension Development Anatomy of an Extension “Hello Flaskext!” Initializing Extensions The Extension Code Using _app_ctx_stack Learn from Others Approved something like this: from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello, World!' So what did that code do? 1. First we imported the Flask class. An instance particular function, and returns the message we want to display in the user’s browser. Just save it as hello.py or something similar. Make sure to not call your application flask.py because this would conflict0 码力 | 428 页 | 895.98 KB | 1 年前3
Flask Documentation (1.1.x)something like this: from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello, World!' So what did that code do? 1. First we imported the Flask class. An instance particular function, and returns the message we want to display in the user’s browser. Just save it as hello.py or something similar. Make sure to not call your application flask.py because this would conflict the application to work with by exporting the FLASK_APP environment variable: $ export FLASK_APP=hello.py $ flask run * Running on http://127.0.0.1:5000/ If you are on Windows, the environment variable0 码力 | 291 页 | 1.25 MB | 1 年前3
Flask入门教程1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11 1.12 1.13 1.14 1.15 目录 简介 前言 第 1 章:准备工作 第 2 章:Hello, Flask! 第 3 章:模板 第 4 章:静态文件 第 5 章:数据库 第 6 章:模板优化 第 7 章:表单 第 8 章:用户认证 第 9 章:测试 第 10 章:组织你的代码 关于作者 我叫李辉,我是《Flask Web 开发实战》的作者,Pallets Team 成员。你可以在我 的个人主页了解更多关于我的信息。 目录 前言 第 1 章:准备工作 第 2 章:Hello, Flask! 第 3 章:模板 第 4 章:静态文件 第 5 章:数据库 第 6 章:模板优化 第 7 章:表单 第 8 章:用户认证 第 9 章:测试 第 10 章:组织你的代码 )。用户安装可以避免破坏全局的包,而且可以避 免对不可信的包使用 sudo pip 导致的潜在安全问题。详情见 Pipenv 文档安装 章节。 第 1 章:准备工作 13 第 2 章:Hello, Flask! 追溯到最初,Flask 诞生于 Armin Ronacher 在 2010 年愚人节开的一个玩笑。后 来,它逐渐发展成为一个成熟的 Python Web 框架,越来越受到开发者的喜爱。目0 码力 | 127 页 | 7.62 MB | 1 年前3
Flask-RESTful Documentation
Release 0.3.6Api app = Flask(__name__) api = Api(app) class HelloWorld(Resource): def get(self): return {'hello': 'world'} api.add_resource(HelloWorld, '/') if __name__ == '__main__': app.run(debug=True) Save environment! Now open up a new prompt to test out your API using curl $ curl http://127.0.0.1:5000/ {"hello": "world"} 1.2.2 Resourceful Routing The main building block provided by Flask-RESTful are resources get(self): # Default to 200 OK return {'task': 'Hello world'} class Todo2(Resource): def get(self): # Set the response code to 201 return {'task': 'Hello world'}, 201 class Todo3(Resource): def get(self):0 码力 | 46 页 | 245.60 KB | 1 年前3
Flask-RESTful Documentation Release 0.3.6= Flask(__name__) api = Api(app) class HelloWorld(Resource): def get(self): return {'hello': 'world'} api.add_resource(HelloWorld, '/') if __name__ == '__main__': app.run(debug=True) environment! Now open up a new prompt to test out your API using curl $ curl http://127.0.0.1:5000/ {"hello": "world"} Resourceful Routing The main building block provided by Flask-RESTful are resources. Default to 200 OK return {'task': 'Hello world'} class Todo2(Resource): def get(self): # Set the response code to 201 return {'task': 'Hello world'}, 201 class Todo3(Resource):0 码力 | 49 页 | 91.90 KB | 1 年前3
Flask-RESTful Documentation
Release 0.3.7Api app = Flask(__name__) api = Api(app) class HelloWorld(Resource): def get(self): return {'hello': 'world'} api.add_resource(HelloWorld, '/') if __name__ == '__main__': app.run(debug=True) Save environment! Now open up a new prompt to test out your API using curl $ curl http://127.0.0.1:5000/ {"hello": "world"} 1.2.2 Resourceful Routing The main building block provided by Flask-RESTful are resources get(self): # Default to 200 OK return {'task': 'Hello world'} class Todo2(Resource): def get(self): # Set the response code to 201 return {'task': 'Hello world'}, 201 class Todo3(Resource): def get(self):0 码力 | 50 页 | 253.09 KB | 1 年前3
Flask-RESTful Documentation
Release 0.3.8Api app = Flask(__name__) api = Api(app) class HelloWorld(Resource): def get(self): return {'hello': 'world'} api.add_resource(HelloWorld, '/') if __name__ == '__main__': app.run(debug=True) Save environment! Now open up a new prompt to test out your API using curl $ curl http://127.0.0.1:5000/ {"hello": "world"} 1.2.2 Resourceful Routing The main building block provided by Flask-RESTful are resources get(self): # Default to 200 OK return {'task': 'Hello world'} class Todo2(Resource): def get(self): # Set the response code to 201 return {'task': 'Hello world'}, 201 class Todo3(Resource): def get(self):0 码力 | 50 页 | 253.64 KB | 1 年前3
Flask-RESTful Documentation Release 0.3.8= Flask(__name__) api = Api(app) class HelloWorld(Resource): def get(self): return {'hello': 'world'} api.add_resource(HelloWorld, '/') if __name__ == '__main__': app.run(debug=True) environment! Now open up a new prompt to test out your API using curl $ curl http://127.0.0.1:5000/ {"hello": "world"} Resourceful Routing The main building block provided by Flask-RESTful are resources. Default to 200 OK return {'task': 'Hello world'} class Todo2(Resource): def get(self): # Set the response code to 201 return {'task': 'Hello world'}, 201 class Todo3(Resource):0 码力 | 55 页 | 93.30 KB | 1 年前3
Flask-RESTful Documentation Release 0.3.7= Flask(__name__) api = Api(app) class HelloWorld(Resource): def get(self): return {'hello': 'world'} api.add_resource(HelloWorld, '/') if __name__ == '__main__': app.run(debug=True) environment! Now open up a new prompt to test out your API using curl $ curl http://127.0.0.1:5000/ {"hello": "world"} Resourceful Routing The main building block provided by Flask-RESTful are resources. Default to 200 OK return {'task': 'Hello world'} class Todo2(Resource): def get(self): # Set the response code to 201 return {'task': 'Hello world'}, 201 class Todo3(Resource):0 码力 | 55 页 | 93.21 KB | 1 年前3
Flask-RESTful Documentation Release 0.3.10= Flask(__name__) api = Api(app) class HelloWorld(Resource): def get(self): return {'hello': 'world'} api.add_resource(HelloWorld, '/') if __name__ == '__main__': app.run(debug=True) environment! Now open up a new prompt to test out your API using curl $ curl http://127.0.0.1:5000/ {"hello": "world"} Resourceful Routing The main building block provided by Flask-RESTful are resources. Default to 200 OK return {'task': 'Hello world'} class Todo2(Resource): def get(self): # Set the response code to 201 return {'task': 'Hello world'}, 201 class Todo3(Resource):0 码力 | 42 页 | 84.60 KB | 1 年前3
共 11 条
- 1
- 2













