Skip to content

Commit c5edb3c

Browse files
committed
List of APIs is now built dynamically.
1 parent 469b538 commit c5edb3c

File tree

1 file changed

+13
-15
lines changed
  • samples/api-python-client-doc

1 file changed

+13
-15
lines changed

samples/api-python-client-doc/main.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,31 @@
1818
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
1919

2020

21+
import httplib2
2122
import inspect
23+
import os
2224
import pydoc
2325
import re
2426

2527
from apiclient.discovery import build
26-
28+
from apiclient.anyjson import simplejson
29+
from google.appengine.api import memcache
2730
from google.appengine.ext import webapp
31+
from google.appengine.ext.webapp import template
2832
from google.appengine.ext.webapp import util
2933

3034

3135
class MainHandler(webapp.RequestHandler):
3236

3337
def get(self):
34-
self.response.out.write("""
35-
<h1>Google API Client for Python Documentation</h1>
36-
<ul>
37-
<li><a href='/buzz/v1'>buzz</a>
38-
<li><a href='/moderator/v1'>moderator</a>
39-
<li><a href='/latitude/v1'>latitude</a>
40-
<li><a href='/customsearch/v1'>customsearch</a>
41-
<li><a href='/diacritize/v1'>diacritize</a>
42-
<li><a href='/translate/v2'>translate</a>
43-
<li><a href='/prediction/v1.1'>prediction</a>
44-
<li><a href='/shopping/v1'>shopping</a>
45-
<li><a href='/urlshortener/v1'>urlshortener</a>
46-
</ul>
47-
""")
38+
http = httplib2.Http(memcache)
39+
resp, content = http.request('https://www.googleapis.com/discovery/v0.3/directory?preferred=true')
40+
directory = simplejson.loads(content)['items']
41+
path = os.path.join(os.path.dirname(__file__), 'index.html')
42+
self.response.out.write(
43+
template.render(
44+
path, {'directory': directory,
45+
}))
4846

4947

5048
def render(resource):

0 commit comments

Comments
 (0)