Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
main.MainHandler Class Reference
Inheritance diagram for main.MainHandler:

Public Member Functions

def get (self, name)
 
def handleLogin (self)
 
def handleDev (self)
 
def handleUpload (self)
 

Detailed Description

Definition at line 187 of file main.py.

Member Function Documentation

◆ get()

def main.MainHandler.get (   self,
  name 
)

Definition at line 190 of file main.py.

190 def get(self, name):
191 if name == 'dev':
192 return self.handleDev()
193
194 elif name == 'login':
195 return self.handleLogin()
196
197 elif name == 'upload':
198 return self.handleUpload()
199
200 user = users.get_current_user()
201 prefs = UserData.get_by_key_name(user.user_id())
202 if prefs is None:
203 return self.handleLogin()
204
205 html = HtmlFile.get_by_key_name(name)
206 if html is None:
207 self.error(404)
208 return
209
210 self.response.headers['Content-Type'] = 'text/html'
211
212 if html.compressed:
213 # TODO(jimhug): This slightly sucks ;-)
214 # Can we write directly to the response.out?
215 gz = gzip.GzipFile(name,
216 'rb',
217 fileobj=StringIO.StringIO(html.content))
218 self.response.out.write(gz.read())
219 gz.close()
220 else:
221 self.response.out.write(html.content)
222
223 # TODO(jimhug): Include first data packet with html.
224
const myers::Point & get(const myers::Segment &)

◆ handleDev()

def main.MainHandler.handleDev (   self)

Definition at line 243 of file main.py.

243 def handleDev(self):
244 user = users.get_current_user()
245 content = template.render('dev.html', {'user': user})
246 self.response.out.write(content)
247

◆ handleLogin()

def main.MainHandler.handleLogin (   self)

Definition at line 225 of file main.py.

225 def handleLogin(self):
226 user = users.get_current_user()
227 # TODO(jimhug): Manage secrets for dart.googleplex.com better.
228 # TODO(jimhug): Confirm that we need client_secret.
229 flow = OAuth2WebServerFlow(
230 client_id='267793340506.apps.googleusercontent.com',
231 client_secret='5m8H-zyamfTYg5vnpYu1uGMU',
232 scope=READER_API,
233 user_agent='swarm')
234
235 callback = self.request.relative_url('/oauth2callback')
236 authorize_url = flow.step1_get_authorize_url(callback)
237
238 memcache.set(user.user_id(), pickle.dumps(flow))
239
240 content = template.render('login.html', {'authorize': authorize_url})
241 self.response.out.write(content)
242

◆ handleUpload()

def main.MainHandler.handleUpload (   self)

Definition at line 248 of file main.py.

248 def handleUpload(self):
249 user = users.get_current_user()
250 content = template.render('upload.html', {'user': user})
251 self.response.out.write(content)
252
253

The documentation for this class was generated from the following file: