Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use 'debug'
- use 'db' with {'host' : 'localhost', 'user' : 'root', 'pass' : '', 'dbname' : 'test'}
- def valid_token token:str
- < :bool !db.query 'SELECT * FROM tokens WHERE key=?' [token]
- end
- str token = io.get 'token'
- if not token
- :: 'no token provided! :(' 400 /* 400 is the HTTP status code for 'Bad Request' */
- exit
- end
- if not valid_token token
- :: 'token "%{token}" is not valid!' 400
- exit
- end
- io.write
- json {
- 'foo' : 'bar',
- 'lol' : 'hi'
- }
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement