# !/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import *
app = Flask(__name__)
@app.route('/')
def index():
return redirect('/login/')
def index():
return u'这是首页11111'
@app.route('/login/')
def logindo():
return u'这是登陆页面2222'
if __name__ == '__main__':
app.run(host='127.0.0.1',port=6001,debug=True)
http://127.0.0.1:6001/login/
# !/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import *
app = Flask(__name__)
@app.route('/')
def index():
return redirect('/login/')
def index():
login_url=url_for('logindo')
return redirect(login_url)
return u'这是首页11111'
@app.route('/login/')
def logindo():
return u'这是登陆页面2222'
if __name__ == '__main__':
app.run(host='127.0.0.1',port=6001,debug=True)
# !/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import *
app = Flask(__name__)
@app.route('/')
def index():
login_url=url_for('logindo')
return redirect(login_url)
return u'这是首页11111'
@app.route('/login/')
def logindo():
return u'这是登陆页面2222'
@app.route('/question/<is_login>/')
def question(is_login):
if is_login=='1':
return u'这是发布问答页面'
else:
return redirect('/login')
if __name__ == '__main__':
app.run(host='127.0.0.1',port=6001,debug=True)
# !/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import *
app = Flask(__name__)
@app.route('/')
def index():
login_url=url_for('logindo')
return redirect(login_url)
return u'这是首页11111'
@app.route('/login/')
def logindo():
return u'这是登陆页面2222'
@app.route('/question/<is_login>/')
def question(is_login):
if is_login=='1':
return u'这是发布问答页面'
else:
return redirect(url_for('logindo'))
if __name__ == '__main__':
app.run(host='127.0.0.1',port=6001,debug=True)
如果没有登录,重定向到登录页面: