try: from urllib3.contrib.appengine import AppEngineManager, is_appengine_sandbox except Exception: def is_appengine_sandbox(): return False try: # Python 2.7+ from collections import OrderedDict except ImportError: from urllib3.packages.ordered_dict import OrderedDict if is_appengine_sandbox(): # AppEngineManager uses AppEngine's URLFetch API behind the scenes _http = AppEngineManager() else: # PoolManager uses a socket-level API behind the scenes _http = PoolManager(cert_reqs='CERT_REQUIRED', ca_certs=certifi.where()) UPLOAD_LARGE_CHUNK_SIZE = 20000000 def upload(file, **options): params = utils.build_upload_params(**options) return call_cacheable_api("upload", params, file=file, **options) def unsigned_upload(file, upload_preset, **options): return upload(file, upload_preset=upload_preset, unsigned=True, **options)
def setUp(self): self.manager = AppEngineManager() self.pool = MockPool(self.host, self.port, self.manager)
def http(): if is_appengine_sandbox: http = AppEngineManager() else: http = PoolManager() return http
def setUp(self): # Disable urlfetch which doesn't respect Retry-After header. self.manager = AppEngineManager(urlfetch_retries=False) self.pool = MockPool(self.host, self.port, self.manager)
from flask import Flask from urllib3 import PoolManager from urllib3.contrib.appengine import AppEngineManager, is_appengine_sandbox from functools import wraps from requests import request from flask import abort from flask import request from flask import render_template http = AppEngineManager() if is_appengine_sandbox() else PoolManager() if not http: raise ValueError("Could not instantiate HTTTP") app = Flask(__name__) authorization_header = "Authorization" token_urlparam = "token" expected_token_length = 256 auth_service_url = "https://security-dot-training-project-lab.appspot.com/" game_engine_url = "https://gameengine-dot-training-project-lab.appspot.com/" lobby_url = "https://lobbyservice-dot-training-project-lab.appspot.com/" def require_authentication(): def decorator(api_method): @wraps(api_method)