티스토리 뷰
./templates/login_form.html
<html>
<head>
<title>login page</title>
</head>
<body>
<form method="post" action="/login">
<h2> try login. </h2>
<input type = "text" name ="id" placeholder="Username">
<input type = "password" name="pw" placeholder="password">
<button type="submit">login</button>
</form>
</body>
</html>
./app.py
from flask import *
app = Flask(__name__)
@app.route('/')
def login_form():
return render_template('login_form.html')
@app.route('/login', methods = ['POST'])
def login():
if request.method == 'POST':
if(request.form['id'] == 'admin' and request.form['pw'] == 'admin123'):
session['logged'] = True
session['user'] = request.form['id']
return 'Hi, ' + request.form['id']
else:
return """<script>alert("wrong!");location.href='/';</script>"""
else:
return """<script>alert("not allowd!");location.href='/';</script>"""
app.secret_key = 'sample_secret'
if __name__ == '__main__':
app.run()
'programming > python' 카테고리의 다른 글
[Flask] app.py 구동 (0) | 2018.08.25 |
---|---|
[Flask] logout 구현 (0) | 2018.08.25 |
[Flask] parameter.py (0) | 2018.08.23 |
[Flask] routing.py (0) | 2018.08.23 |
[Flask] hello.py (0) | 2018.08.23 |
- glibc
- oob
- pwnable
- tcache
- stack reusing
- heap
- shellcoding
- pwnable.tw
- 본선가고싶다
- hacking
- codegate
- exit
- 해킹
- fsop
- HackCTF
- srop
- TLS
- FSB
- SQLi
- overflow
- fastbin
- fastbindup
- ebp change
- rt_sigreturn
- pwable
- Total
- Today
- Yesterday