<reponame>yanfeng12/MyPythonCode<gh_stars>0
from flask import Flask, session


from checker import check_logged_in


app = Flask(__name__)


@app.route('/')
def hello() -> str:
    return 'Hello from the simple webapp.'


@app.route('/login')
def do_login() -> str:
    session['logged_in'] = True
    return 'You are now logged in.'


app.secret_key = 'YouWillNeverGuessMySecretKey'


@app.route('/logout')
def do_logout() -> str:
    session.pop('logged_in')
    return 'You are now logged out.'


@app.route('/status')
def check_status() -> str:
    if 'logged_in' in session:
        return 'You are currently logged in.'
    return 'You sre not logged in.'


@app.route('/page1')
@check_logged_in
def page1() -> str:
    return 'This is page1.'


@app.route('/page2')
@check_logged_in
def page2() -> str:
    return 'This is page2.'


@app.route('/page3')
@check_logged_in
def page3() -> str:
    return 'This is page3.'


if __name__ == '__main__':
    app.run(debug=True)

from flask import Flask, session


from checker import check_logged_in


app = Flask(__name__)


@app.route('/')
def hello() -> str:
    return 'Hello from the simple webapp.'


@app.route('/login')
def do_login() -> str:
    session['logged_in'] = True
    return 'You are now logged in.'


app.secret_key = 'YouWillNeverGuessMySecretKey'


@app.route('/logout')
def do_logout() -> str:
    session.pop('logged_in')
    return 'You are now logged out.'


@app.route('/status')
def check_status() -> str:
    if 'logged_in' in session:
        return 'You are currently logged in.'
    return 'You sre not logged in.'


@app.route('/page1')
@check_logged_in
def page1() -> str:
    return 'This is page1.'


@app.route('/page2')
@check_logged_in
def page2() -> str:
    return 'This is page2.'


@app.route('/page3')
@check_logged_in
def page3() -> str:
    return 'This is page3.'


if __name__ == '__main__':
    app.run(debug=True)