当前位置:网站首页>flask框架中页面跳转与重定向
flask框架中页面跳转与重定向
2022-07-24 03:51:00 【IT之一小佬】
示例代码1:
from flask import Flask, redirect, url_for
app = Flask(__name__)
@app.route('/')
def index():
login_url = url_for('login')
return redirect(login_url)
@app.route('/login')
def login():
return '这是登陆页面'
if __name__ == '__main__':
app.run(debug=True)

示例代码2:
from flask import Flask, request, redirect, url_for
app = Flask(__name__)
@app.route('/')
def login():
return 'login'
@app.route('/profile/')
def profile():
name = request.args.get('name')
if not name:
return redirect('http://www.baidu.com') # 注意:如果这儿直接写www.baidu.com是不能实现重定向的,是url的拼接
else:
return redirect(url_for('login'))
if __name__ == '__main__':
app.run(debug=True)

边栏推荐
- Histone research -- Characteristics and literature references of histones in Worthington calf thymus
- Remember an online sql deadlock accident: how to avoid deadlock?
- The impact of Patrick mchardy incident on the open source community
- Learning summary | truly record what mindspire two-day training camp can bring to you (1)!
- Y74. Chapter IV Prometheus large factory monitoring system and practice -- Introduction to promql and monitoring pod resources (V)
- IO stream sorting
- 会话技术相关
- How to protect JDBC applications from SQL injection
- leetcode hot 100(刷題篇8)(232/88/451/offer10/offer22/344/)
- The progress in the stack will consume functions that cannot meet the needs of the enterprise. We are committed to
猜你喜欢

Opening soon | openatom openharmony sub forum of 2022 open atom global open source summit "interconnection of all things, enabling thousands of industries"

6-15 vulnerability exploitation SMB rce remote command execution
![[development technology] spingboot database and Persistence technology, JPA, mongodb, redis](/img/fb/bb4a26699e5ec10c6881a4c95ac767.png)
[development technology] spingboot database and Persistence technology, JPA, mongodb, redis

Extend the connection boundary, expand the business scope, and comprehensively move towards the era of Intelligent Cloud network 2.0

Convert the pseudo array returned by childNodes into a true array

Machine learning notes - image homography estimation based on deep learning (homographynet)

Prosci Lag3 antibody: improve in vitro research and help cancer immunotherapy

Worthington's test of hepatocyte separation system and related optimization schemes

Solution to the problem of "out of sight, out of mind, out of order" in the training competition

MLP-多层感知机
随机推荐
STL set container
Pat class a 1040 long symmetric string
复杂嵌套的对象池(5)——对象池的统一管理和拓展
PAT甲级 1041 Be Unique
oh-my-zsh
Convert the pseudo array returned by childNodes into a true array
Worthington hydroxysteroid dehydrogenase technical description and determination scheme
93. (leaflet chapter) leaflet situation plotting - modification of attack direction
。 When calling, the incoming t refers to the Devi pass, which basically asks T2,
因此可命令传递给系统内由用户确稳定。对于主的
【新手向 】手把手开发一个易于扩展的 Tabs 组件
PAT甲级 1043 Is It a Binary Search Tree
How to protect JDBC applications from SQL injection
Worthington's test of hepatocyte separation system and related optimization schemes
C language classic exercises (2) - "bubble sort"“
DOM related method concepts
Svg image color modification is not fancy
Embedded system transplantation [5] - Cross compilation tool chain
Genesis public chain: Tamp the foundation of Web 3.0 development
H7-tool serial port offline burning operation instructions, support TTL serial port, RS232 and RS485 (2022-06-30)