当前位置: 首页>>代码示例>>Python>>正文


Python config.host方法代码示例

本文整理汇总了Python中config.host方法的典型用法代码示例。如果您正苦于以下问题:Python config.host方法的具体用法?Python config.host怎么用?Python config.host使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在config的用法示例。


在下文中一共展示了config.host方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_auth_token

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def get_auth_token(fb_auth_token, fb_user_id):
    if "error" in fb_auth_token:
        return {"error": "could not retrieve fb_auth_token"}
    if "error" in fb_user_id:
        return {"error": "could not retrieve fb_user_id"}
    url = config.host + '/v2/auth/login/facebook'
    req = requests.post(url,
                        headers=headers,
                        data=json.dumps(
                            {'token': fb_auth_token, 'facebook_id': fb_user_id})
                        )
    try:
        tinder_auth_token = req.json()["data"]["api_token"]
        headers.update({"X-Auth-Token": tinder_auth_token})
        get_headers.update({"X-Auth-Token": tinder_auth_token})
        print("You have been successfully authorized!")
        return tinder_auth_token
    except Exception as e:
        print(e)
        return {"error": "Something went wrong. Sorry, but we could not authorize you."} 
开发者ID:fbessez,项目名称:Tinder,代码行数:22,代码来源:tinder_api.py

示例2: change_preferences

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def change_preferences(**kwargs):
    '''
    ex: change_preferences(age_filter_min=30, gender=0)
    kwargs: a dictionary - whose keys become separate keyword arguments and the values become values of these arguments
    age_filter_min: 18..46
    age_filter_max: 22..55
    age_filter_min <= age_filter_max - 4
    gender: 0 == seeking males, 1 == seeking females
    distance_filter: 1..100
    discoverable: true | false
    {"photo_optimizer_enabled":false}
    '''
    try:
        url = config.host + '/profile'
        r = requests.post(url, headers=headers, data=json.dumps(kwargs))
        return r.json()
    except requests.exceptions.RequestException as e:
        print("Something went wrong. Could not change your preferences:", e) 
开发者ID:fbessez,项目名称:Tinder,代码行数:20,代码来源:tinder_api.py

示例3: gif_query

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def gif_query(query, limit=3):
  try:
      url = config.host + '/giphy/search?limit=%s&query=%s' % (limit, query)
      r = requests.get(url, headers=headers)
      return r.json()
  except requests.exceptions.RequestException as e:
      print("Something went wrong. Could not get your gifs:", e)


# def see_friends():
#     try:
#         url = config.host + '/group/friends'
#         r = requests.get(url, headers=headers)
#         return r.json()['results']
#     except requests.exceptions.RequestException as e:
#         print("Something went wrong. Could not get your Facebook friends:", e) 
开发者ID:fbessez,项目名称:Tinder,代码行数:18,代码来源:tinder_api.py

示例4: json

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def json(self):
    resp = {
      "id": self.id,
      "doi": self.doi,
      "first_posted": self.posted.strftime('%Y-%m-%d') if self.posted is not None else "",
      "biorxiv_url": self.url,
      "url":  f"{config.host}/v1/papers/{self.id}",
      "title": self.title,
      "category": self.collection,
      "abstract": self.abstract,
      "authors": [x.json() for x in self.authors],
      "ranks": self.ranks.json()
    }
    if self.pub_doi is not None:
      resp["publication"] = {
        "journal": self.publication,
        "doi": self.pub_doi
      }
    else:
      resp["publication"] = {}
    return resp 
开发者ID:blekhmanlab,项目名称:rxivist,代码行数:23,代码来源:models.py

示例5: analytics

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def analytics(short_url):

	info_fetch , counter_fetch , browser_fetch , platform_fetch = list_data(short_url)
	return render_template("data.html" , host = shorty_host,info = info_fetch ,counter = counter_fetch ,\
	 browser = browser_fetch , platform = platform_fetch) 
开发者ID:highoncarbs,项目名称:shorty,代码行数:7,代码来源:app.py

示例6: search

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def search():
	s_tag = request.form.get('search_url')
	if s_tag == "":
		return render_template('index.html', error = "Please enter a search term")
	else:
		conn = MySQLdb.connect(host , user , passwrd, db)
		cursor = conn.cursor()
		
		search_tag_sql = "SELECT * FROM WEB_URL WHERE TAG = %s" 
		cursor.execute(search_tag_sql , (s_tag, ) )
		search_tag_fetch = cursor.fetchall()
		conn.close()
		return render_template('search.html' , host = shorty_host , search_tag = s_tag , table = search_tag_fetch ) 
开发者ID:highoncarbs,项目名称:shorty,代码行数:15,代码来源:app.py

示例7: list_data

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def list_data(shorty_url):
	
	"""
		Takes short_url for input.
		Returns counter , browser , platform ticks. 
	"""
	conn = MySQLdb.connect(host , user , passwrd, db)
	cursor = conn.cursor()
	su =[shorty_url]
	info_sql = "SELECT URL , S_URL ,TAG FROM WEB_URL WHERE S_URL= %s; "
	counter_sql = "SELECT COUNTER FROM WEB_URL WHERE S_URL= %s; "
	browser_sql = "SELECT CHROME , FIREFOX , SAFARI, OTHER_BROWSER FROM WEB_URL WHERE S_URL =%s;"
	platform_sql = "SELECT ANDROID , IOS , WINDOWS, LINUX , MAC , OTHER_PLATFORM FROM WEB_URL WHERE S_URL = %s;"	
	
	
	# MySQLdb's execute() function expects a list
	# of objects to be converted so we use [arg ,]
	# But for sqlite ( args,) works. 
	
	
	cursor.execute(info_sql , su)
	info_fetch = cursor.fetchone()
	cursor.execute(counter_sql , su)
	counter_fetch = cursor.fetchone()
	cursor.execute(browser_sql,su)
	browser_fetch = cursor.fetchone()
	cursor.execute(platform_sql, su)
	platform_fetch = cursor.fetchone()
	conn.close()
	return info_fetch , counter_fetch , browser_fetch , platform_fetch 
开发者ID:highoncarbs,项目名称:shorty,代码行数:32,代码来源:display_list.py

示例8: __init__

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def __init__(self, config):
        # Prepare the connection to the server
        self.oerp = oerplib.OERP(config.host, protocol=config.protocol, port=config.port)

        # Login (the object returned is a browsable record)
        user = self.oerp.login(config.user, config.password, config.db_name) 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:8,代码来源:conftest.py

示例9: get_updates

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def get_updates(last_activity_date=""):
    '''
    Returns all updates since the given activity date.
    The last activity date is defaulted at the beginning of time.
    Format for last_activity_date: "2017-07-09T10:28:13.392Z"
    '''
    try:
        url = config.host + '/updates'
        r = requests.post(url,
                          headers=headers,
                          data=json.dumps({"last_activity_date": last_activity_date}))
        return r.json()
    except requests.exceptions.RequestException as e:
        print("Something went wrong with getting updates:", e) 
开发者ID:fbessez,项目名称:Tinder,代码行数:16,代码来源:tinder_api.py

示例10: get_self

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def get_self():
    '''
    Returns your own profile data
    '''
    try:
        url = config.host + '/profile'
        r = requests.get(url, headers=headers)
        return r.json()
    except requests.exceptions.RequestException as e:
        print("Something went wrong. Could not get your data:", e) 
开发者ID:fbessez,项目名称:Tinder,代码行数:12,代码来源:tinder_api.py

示例11: get_meta

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def get_meta():
    '''
    Returns meta data on yourself. Including the following keys:
    ['globals', 'client_resources', 'versions', 'purchases',
    'status', 'groups', 'products', 'rating', 'tutorials',
    'travel', 'notifications', 'user']
    '''
    try:
        url = config.host + '/meta'
        r = requests.get(url, headers=headers)
        return r.json()
    except requests.exceptions.RequestException as e:
        print("Something went wrong. Could not get your metadata:", e) 
开发者ID:fbessez,项目名称:Tinder,代码行数:15,代码来源:tinder_api.py

示例12: update_location

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def update_location(lat, lon):
    '''
    Updates your location to the given float inputs
    Note: Requires a passport / Tinder Plus
    '''
    try:
        url = config.host + '/passport/user/travel'
        r = requests.post(url, headers=headers, data=json.dumps({"lat": lat, "lon": lon}))
        return r.json()
    except requests.exceptions.RequestException as e:
        print("Something went wrong. Could not update your location:", e) 
开发者ID:fbessez,项目名称:Tinder,代码行数:13,代码来源:tinder_api.py

示例13: reset_real_location

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def reset_real_location():
    try:
        url = config.host + '/passport/user/reset'
        r = requests.post(url, headers=headers)
        return r.json()
    except requests.exceptions.RequestException as e:
        print("Something went wrong. Could not update your location:", e) 
开发者ID:fbessez,项目名称:Tinder,代码行数:9,代码来源:tinder_api.py

示例14: get_recs_v2

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def get_recs_v2():
    '''
    This works more consistently then the normal get_recommendations becuase it seeems to check new location
    '''
    try:
        url = config.host + '/v2/recs/core?locale=en-US'
        r = requests.get(url, headers=headers)
        return r.json()
    except Exception as e:
        print('excepted') 
开发者ID:fbessez,项目名称:Tinder,代码行数:12,代码来源:tinder_api.py

示例15: set_webprofileusername

# 需要导入模块: import config [as 别名]
# 或者: from config import host [as 别名]
def set_webprofileusername(username):
    '''
    Sets the username for the webprofile: https://www.gotinder.com/@YOURUSERNAME
    '''
    try:
        url = config.host + '/profile/username'
        r = requests.put(url, headers=headers,
                         data=json.dumps({"username": username}))
        return r.json()
    except requests.exceptions.RequestException as e:
        print("Something went wrong. Could not set webprofile username:", e) 
开发者ID:fbessez,项目名称:Tinder,代码行数:13,代码来源:tinder_api.py


注:本文中的config.host方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。