Flask入门教程http://localhost:5000/hello 。 整个请求的处理过程如下所示: 1. 当用户在浏览器地址栏访问这个地址,在这里即 http://localhost:5000/ 2. 服务器解析请求,发现请求 URL 匹配的 URL 规则是 / ,因此调用对应的处 理函数 hello() 3. 获取 hello() 函数的返回值,处理后返回给客户端(浏览器) 4. 浏览器接受响应,将其显示在窗口上 首先,你可以自由修改视图函数的返回值,比如: @app.route('/') def hello(): return u'欢迎来到我的 Watchlist!' 返回值作为响应的主体,默认会被浏览器作为 HTML 格式解析,所以我们可以添加 一个 HTML 元素标记: @app.route('/') def hello(): return 'Hello Totoro!
0 码力 | 127 页 | 7.62 MB | 1 年前
3
Flask Documentation (1.1.x)this: /home/user/Projects/flask-tutorial ├── flaskr/ │ ├── __init__.py │ ├── db.py │ ├── schema.sql │ ├── auth.py │ ├── blog.py │ ├── templates/ │ │ ├── base.html │ │ ├── auth/ │ │ └── update.html │ └── static/ │ └── style.css ├── tests/ │ ├── conftest.py │ ├── data.sql │ ├── test_factory.py │ ├── test_db.py │ ├── test_auth.py │ └── test_blog.py ├── venv/ ├── become big, you may want to switch to a different database. The tutorial doesn’t go into detail about SQL. If you are not familiar with it, the SQLite docs describe the language [https://sqlite.org/lang.html]0 码力 | 428 页 | 895.98 KB | 1 年前3
Flask Documentation (1.1.x)__init__.py db.py schema.sql auth.py blog.py templates/ base.html auth/ login.html register.html blog/ create.html index.html update.html static/ style.css tests/ conftest.py data.sql test_factory.py test_db become big, you may want to switch to a different database. The tutorial doesn’t go into detail about SQL. If you are not familiar with it, the SQLite docs describe the language. Connect to the Database user table, and posts in the post table. Create a file with the SQL commands needed to create empty tables: Listing 5: flaskr/schema.sql DROP TABLE IF EXISTS user; DROP TABLE IF EXISTS post; (continues0 码力 | 291 页 | 1.25 MB | 1 年前3
共 3 条
- 1













