Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. use 'debug'
  2. use 'db' with {'host' : 'localhost', 'user' : 'root', 'pass' : '', 'dbname' : 'test'}
  3.  
  4. def valid_token token:str
  5.     < :bool !db.query 'SELECT * FROM tokens WHERE key=?' [token]
  6. end
  7.  
  8. str token = io.get 'token'
  9.  
  10. if not token
  11.     :: 'no token provided! :(' 400  /* 400 is the HTTP status code for 'Bad Request' */
  12.     exit
  13. end
  14.  
  15. if not valid_token token
  16.     :: 'token "%{token}" is not valid!' 400
  17.     exit
  18. end
  19.  
  20. io.write
  21.     json {
  22.         'foo' : 'bar',
  23.         'lol' : 'hi'
  24.     }
  25. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement