Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Created Jul 8, 2016
Embed
What would you like to do?
【Python】bottleでPOST送信
from bottle import route, run, request
import os
@route("/login")
def login():
return """
<form action="/login" method="post">
Username: <input name="username" type="text" />
Password: <input name="password" type="password" />
<input value="Login" type="submit" />
</form>
"""
@route("/login", method="POST")
def do_login():
username = request.forms.get("username")
password = request.forms.get("password")
if check_login(username, password):
return "<p>Your ligin infomation was correct.</p>"
else:
return "<p>Login failed.</p>"
def check_login(username, password):
if username == "user" and password == "pass":
return True
else:
return False
run(host="0.0.0.0", port=int(os.environ.get("PORT", 5000)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment