Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- import Cookie
- USERNAME = "<user_name>"
- PASSWORD = "<password>"
- BACKEND = "https://blahblah.com"
- # login will take orgId, email and password and return auth cookie for the user
- def login(email, password):
- url = 'https://auth-v2.blahblah.com/auth/v1.0/login'
- data = json.dumps({'email':email, 'password': password})
- r = requests.post(url,data=data,allow_redirects=False)
- cookieHeaders = filter(lambda x: x.lower()=='set-cookie',r.headers.keys())
- if len(cookieHeaders)==0:
- return None
- bc = Cookie.BaseCookie(r.headers[cookieHeaders[0]])
- sess = 'sess='+bc.values()[0].value
- return sess
- foo = [1,2,3,4,5]
- len(filter(lambda x: x>2, foo))
- foo = [1,2,3,4,5]
- len(list(filter(lambda x: x>2, foo)))
Add Comment
Please, Sign In to add comment