Created
October 17, 2019 10:12
-
-
Save Rhyanz46/f86ea7b46edc3663f84d61046420e63f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, abort | |
app = Flask('aplikasi pertama') | |
session_nya = {} | |
@app.route('/login') | |
def login(): | |
if not session_nya.get('user'): | |
session_nya['user'] = "arian" | |
return 'berhasil login' | |
abort(400, pesan='anda sudah login sebelumnya') | |
@app.route('/home') | |
def rumah(): | |
if not session_nya.get('user'): | |
abort(403, pesan="anda belum login") | |
return "hai " + session_nya['user'] | |
@app.route('/setting') | |
def setting(): | |
if not session_nya.get('user'): | |
abort(403, pesan="anda belum login") | |
return "ini halaman sesttingmu " + session_nya['user'] + " :)" | |
@app.route('/logout') | |
def logout(): | |
if not session_nya.get('user'): | |
abort(403, pesan="anda belum login") | |
session_nya.pop('user') | |
return "berhasil logout" | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment