This repository has been archived by the owner on May 9, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robert Rees
committed
Nov 16, 2012
1 parent
0fcfa7d
commit ede6f60
Showing
7 changed files
with
64 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,7 @@ | ||
import webapp2 | ||
import jinja2 | ||
import os | ||
import json | ||
import logging | ||
from urllib import quote, urlencode | ||
from google.appengine.api import urlfetch | ||
import handlers | ||
|
||
jinja_environment = jinja2.Environment( | ||
loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates"))) | ||
|
||
class MainPage(webapp2.RequestHandler): | ||
def get(self): | ||
template = jinja_environment.get_template('index.html') | ||
|
||
template_values = {} | ||
|
||
self.response.out.write(template.render(template_values)) | ||
|
||
app = webapp2.WSGIApplication([('/', MainPage)], | ||
app = webapp2.WSGIApplication([('/', handlers.MainPage), | ||
('/api/most-viewed', handlers.MostViewed), | ||
], | ||
debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
application: your-app-id | ||
application: gu-most-popular | ||
version: 1 | ||
runtime: python27 | ||
api_version: 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import webapp2 | ||
import jinja2 | ||
import os | ||
import json | ||
import logging | ||
|
||
from urllib import quote, urlencode | ||
from google.appengine.api import urlfetch | ||
|
||
import headers | ||
import ophan | ||
|
||
jinja_environment = jinja2.Environment( | ||
loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), "templates"))) | ||
|
||
class MainPage(webapp2.RequestHandler): | ||
def get(self): | ||
template = jinja_environment.get_template('index.html') | ||
|
||
template_values = {} | ||
|
||
self.response.out.write(template.render(template_values)) | ||
|
||
class MostViewed(webapp2.RequestHandler): | ||
def get(self): | ||
headers.json(self.response) | ||
|
||
ophan_json = ophan.popular() | ||
self.response.out.write(ophan_json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from google.appengine.api.urlfetch import fetch | ||
from google.appengine.api import memcache | ||
|
||
import settings | ||
import logging | ||
|
||
client = memcache.Client() | ||
|
||
|
||
def popular(section_id = None): | ||
most_read_url = "http://%s/api/mostread" % client.get("OPHAN_HOST") | ||
|
||
result = fetch(most_read_url) | ||
|
||
if result.status_code == 200: | ||
return result.content | ||
return None |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters