Last active
February 23, 2018 15:44
-
-
Save DYelamos/35f8d2e530edf86274b7c9f8e6e98a53 to your computer and use it in GitHub Desktop.
This file contains 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 bottle import *# or route | |
import json | |
app = Bottle() | |
@app.get('/login') # or @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> | |
''' | |
@app.get('/') # or @route('/login') | |
def login(): | |
return "welcome to my api" | |
@app.post('/json') # or @route('/login', method='POST') | |
def do_json(): | |
#username=request.json['username'] | |
#password=request.json['password'] | |
data = json.loads(request.json) | |
return data["username"] + " " + data["password"] | |
@app.post('/login') # or @route('/login', method='POST') | |
def do_login(): | |
username = request.forms.get('username') | |
password = request.forms.get('password') | |
if username!="" and password!="": | |
return "<p>Your login information was correct.</p>" | |
else: | |
return "<p>Login failed.</p>" | |
run(app, host='localhost', port=8080, reloader=True) | |
this is about the second revistion
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a comment testing the first revision