Skip to content

Instantly share code, notes, and snippets.

@camelcaseblog

camelcaseblog/01 webapp.py

Last active Jan 29, 2019
Embed
What would you like to do?
import hashlib
from bottle import run, post, request, HTTPResponse
def check_password(username, password):
hashed_password = hashlib.md5(password.encode('utf-8')).hexdigest()
return username == "0501234567" and hashed_password == '24fdf987d78b1f6d7c6008e7ecffeefb': # md5 of 01011980
@post('/login')
def login():
if check_password(request.json['username'], request.json['password']):
return HTTPResponse(status=200)
else:
return HTTPResponse(status=401)
run(host='localhost', port=8080)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.