Created
October 22, 2010 07:51
-
-
Save kixxauth/640125 to your computer and use it in GitHub Desktop.
Insult server tutorial.
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
import logging | |
import time | |
import base_handler | |
class InsultServer(base_handler.BaseHandler): | |
def get(self): | |
# Log the user agent just for fun. | |
logging.info(self.user_agent_repr) | |
response = base_handler.Response( | |
'You are nothing but a lewd-minded ooze of dankish Sun IPC manuals.') | |
response.mime_type = 'text/plain' | |
# Expire in 4 days. | |
response.expires = int(time.time()) + (86400 * 4) | |
# Include analytics. | |
return self.finalize_response(response) | |
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
from google.appengine.ext.webapp.util import run_bare_wsgi_app | |
from werkzeug.routing import Map, Rule, RequestRedirect | |
from fwerks import App | |
import simple_handlers | |
import datastore_handlers | |
import exception_handlers | |
# Your import goes here: | |
import insult_handler | |
# Skip down to: | |
url_map = Map([ | |
Rule('/', endpoint='home') | |
# URL for the insult server. | |
, Rule('/insult_me', endpoint='insults') | |
, Rule('/insult_me/', endpoint='insults') | |
, Rule('/projects', endpoint='projects') | |
, Rule('/projects/', endpoint='projects') | |
, Rule('/join', endpoint='join') | |
, Rule('/about', endpoint='about') | |
, Rule('/datastore/members/', endpoint='datastore_members') | |
, Rule('/datastore/subscribers/', endpoint='datastore_subscribers') | |
, Rule('/datastore/actions/', endpoint='datastore_actions') | |
, Rule('/exception', endpoint='exception') | |
]) | |
handlers = { | |
'home': SimpleHandler | |
# Add the insult server | |
, 'insults': insult_handler.InsultServer | |
, 'projects': SimpleHandler | |
, 'join': SimpleHandler | |
, 'about': SimpleHandler | |
, 'datastore_members': DatastoreMembers | |
, 'datastore_subscribers': DatastoreSubscribers | |
, 'datastore_actions': DatastoreActions | |
, 'exception': TestException | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment