Пример #1
0
    game, gameDbEntry = _getGame(game_id)
    game.total_rows = total_rows


debug_enabled = True

services = {
    'mastermind.newGame': newGame,
    'mastermind.getGameState': getGameState,
    'mastermind.getCurrentRow': getCurrentRow,
    'mastermind.setRow': setRow,
    'mastermind.setPipInRow': setPipInRow,
    'mastermind.getCode': getCode,
    'mastermind.setCode': setCode,
    'mastermind.getLastScore': getLastScore,
    'mastermind.getLastRow': getLastRow,
    'mastermind.getPipsPerRow': getPipsPerRow,
    'mastermind.setPipsPerRow': setPipsPerRow,
    'mastermind.getColorRange': getColorRange,
    'mastermind.setColorRange': setColorRange,
    'mastermind.getSelectedColor': getSelectedColor,
    'mastermind.setSelectedColor': setSelectedColor,
    'mastermind.getTotalRows': getTotalRows,
    'mastermind.setTotalRows': setTotalRows,
}

gateway = WebAppGateway(services, logger=logging, debug=debug_enabled)

application_paths = [('/', gateway), ('/mm', MasterMind)]
app = webapp.WSGIApplication(application_paths, debug=debug_enabled)
Пример #2
0
    rows = []
    fields = ['title', 'url']
    if result.status_code == 200:
      json = simplejson.loads(result.content)
      feed = json['feed']
      entries = []
      if 'entry' in feed:
        entries = feed['entry']
      for entry in entries:
        row_info = {}
        dont_append = False
        for field in fields:
          if not entry['gsx$' + field] or len(entry['gsx$' + field]['$t']) == 0:
            dont_append = True
          row_info[field] = entry['gsx$' + field]['$t']
        if not dont_append:
          rows.append(row_info)
    return rows


application = webapp.WSGIApplication(
                                     [('/', HomePage),
                                      ('/opml', FeedOPML)],
                                     debug=True)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()
Пример #3
0
def main():
    run_wsgi_app(webapp.WSGIApplication([
        ('/creategeo', CreateGeoWorker),
    ]))
Пример #4
0
from google.appengine.ext.webapp.util import run_wsgi_app
from webapp2_extras.routes import RedirectRoute

from gae_bingo import cache, dashboard, middleware, plots, blotter, api, redirect

application = webapp.WSGIApplication([
    ("/gae_bingo/persist", cache.PersistToDatastore),
    ("/gae_bingo/log_snapshot", cache.LogSnapshotToDatastore),
    ("/gae_bingo/blotter/ab_test", blotter.AB_Test),
    ("/gae_bingo/blotter/bingo", blotter.Bingo),

    ("/gae_bingo/redirect", redirect.Redirect),

    ("/gae_bingo", dashboard.Dashboard),
    RedirectRoute('/gae_bingo/dashboard', redirect_to='/gae_bingo'),
    ("/gae_bingo/dashboard/archives", dashboard.Dashboard),
    ("/gae_bingo/dashboard/export", dashboard.Export),

    ("/gae_bingo/api/v1/experiments", api.Experiments),
    ("/gae_bingo/api/v1/experiments/summary", api.ExperimentSummary),
    ("/gae_bingo/api/v1/experiments/conversions", api.ExperimentConversions),
    ("/gae_bingo/api/v1/experiments/control", api.ControlExperiment),
    ("/gae_bingo/api/v1/experiments/notes", api.NoteExperiment),
    ("/gae_bingo/api/v1/alternatives", api.Alternatives),

])
application = middleware.GAEBingoWSGIMiddleware(application)

def main():
    run_wsgi_app(application)
Пример #5
0
        if session.has_key('msg'):
            d['msg'] = session['msg']
            del session['msg'] # only show the message once

        if session.has_key('pvsli'):
            session['pvsli'] += 1
            d['user'] = session['me']
            d['num_now'] = session['pvsli']
        self.render_template("index.html", d)

class LogoutPage(webapp.RequestHandler):
    def get(self):
        session = get_current_session()
        if session.has_key('me'):
            # update the user's record with total views
            user = session['me']
            user.past_view_count += session['pvsli']
            user.put()
            session.terminate()
            redirect_with_msg(self, 'Logout complete: goodbye ' + user.display_name)
        else:
            redirect_with_msg(self, "How silly, you weren't logged in")

application = webapp.WSGIApplication([('/', MainPage),
                                      ('/logout', LogoutPage),
                                      ('/rpx_response', RPXTokenHandler),
                                     ])

def main(): run_wsgi_app(application)
if __name__ == '__main__': main()
          <form action="/sign" method="post">
            <div><textarea name="content" rows="3" cols="60"></textarea></div>
            <div><input type="submit" value="Sign Guestbook"></div>
          </form>
        </body>
      </html>""")


class Guestbook(webapp.RequestHandler):
    def post(self):
        greeting = Greeting()

        if users.get_current_user():
            greeting.author = users.get_current_user()

        greeting.content = self.request.get('content')
        greeting.put()
        self.redirect('/')


application = webapp.WSGIApplication([('/', MainPage), ('/sign', Guestbook)],
                                     debug=True)


def main():
    run_wsgi_app(application)


if __name__ == '__main__':
    main()
Пример #7
0
def main():
    application = webapp.WSGIApplication([('/', MainPage),
                                          ('/ss', SingleScraping),
                                          ('/csvout', CsvOut)],
                                         debug=True)
    wsgiref.handlers.CGIHandler().run(application)
Пример #8
0
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from ordering.station_connection_manager import workstation_connected, workstation_disconnected


class ChannelHandler(webapp.RequestHandler):
    def post(self, *args):
        channel_id = self.request.POST["from"]
        if self.request.path.endswith("/connected/"):
            workstation_connected(channel_id)
        else:
            workstation_disconnected(channel_id)


application = webapp.WSGIApplication([(".*", ChannelHandler)])


def main():
    run_wsgi_app(application)


if __name__ == "__main__":
    main()
Пример #9
0
def main():
    application = webapp.WSGIApplication([('/', FrontPageHandler),
                                          ('/shell.do', StatementHandler)],
                                         debug=_DEBUG)
    wsgiref.handlers.CGIHandler().run(application)
Пример #10
0
#导入GAE数据模块代码
class SightingForm(djangoforms.ModelForm):
    #使用模型创建一个表单
    class Meta:
        model = hfwwgDB.Sighting


        #继承'django.ModelForm'类
class SigthingInputPage(webapp.RequestHandler):
    #连接处理器类名,它提供了 get 的方法来响应请求
    def get(self):
        html = template.render('templates/header.html',
                               {'title': 'Report a Possible Sighting'})
        html = html + template.render('templates/form_start.html', {})
        html = html + str(SightingForm())
        html = html + template.render('templates/form_start.html',
                                      {'sub_title': 'Submit Sighting'})
        html = html + template.render('templates/form_start.html',
                                      {'link': ''})
        self.response.out.write(html)


app = webapp.WSGIApplication([('/,*', SigthingInputPage)], debug=true)


def main():
    run_wsgi_app(app)


if __name__ == '__main__':
    main()
Пример #11
0
        self.delete = isTrue(self.request.GET.get('delete', 'true'))

        namespace_manager.set_namespace('')
        try:
            exceptions = self.GetQuery(order='-minor_version').fetch(
                self.max_results)
        except db.NeedIndexError:

            exceptions = self.GetQuery().fetch(self.max_results)

        if exceptions:
            report = self.GenerateReport(exceptions)
            if self.debug:
                self.response.out.write(report)
            else:
                self.SendReport(report)

            if self.delete:
                db.delete(exceptions)


application = webapp.WSGIApplication([('.*', ReportGenerator)])


def main():
    run_wsgi_app(application)


if __name__ == '__main__':
    main()
Пример #12
0
def main():
    util.run_wsgi_app(webapp.WSGIApplication([(r"/", HomeHandler)]))
Пример #13
0
from os.path import join, dirname
sys.path.insert(0, dirname(__file__))
sys.path.insert(0, dirname(dirname(__file__)))

import util
import controller

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

debug = util.is_dev()
application = webapp.WSGIApplication([
    ('/', controller.Root),
    ('/console/dashboard/', controller.Dashboard),
    ('/console/help.*', controller.Help),
    ('/console/statement', controller.Statement),
    ('/console/banner', controller.Banner),
    ('/console.*', controller.Console),
],
                                     debug=debug)


def main():
    if debug:
        logging.getLogger().setLevel(logging.DEBUG)
    run_wsgi_app(application)


if __name__ == "__main__":
    main()
Пример #14
0
import os

from google.appengine.ext import webapp
from google.appengine.ext.webapp import util

import ndb


class Greeting(ndb.Model):
    message = ndb.StringProperty()
    userid = ndb.IntegerProperty()  # Not used here, but later


class HomePage(webapp.RequestHandler):
    def get(self):
        msg = Greeting.get_or_insert('hello', message='Hello world')
        self.response.out.write(msg.message)


urls = [('/.*', HomePage)]
app = ndb.toplevel(webapp.WSGIApplication(urls))


def main():
    util.run_wsgi_app(app)


if __name__ == '__main__':
    main()
Пример #15
0
        new_sighting = hfwwgDB.Sighting(
        )  # create a new Sighting object to hold your data
        new_sighting.name = self.request.get('name')
        new_sighting.email = self.request.get('email')
        new_sighting.date = self.request.get('date')
        new_sighting.time = self.request.get('time')
        new_sighting.location = self.request.get('location')
        new_sighting.fin_type = self.request.get('fin_type')
        new_sighting.whale_type = self.request.get('whale_type')
        new_sighting.blow_type = self.request.get('blow_type')
        new_sighting.wave_type = self.request.get('wave_type')
        #new_sightine.which_user = users.get_current_user()	# this line includes the Google ID of the currently logged-in user
        new_sighting.put()  # store your data in the GAE datastore
        html = template.render('templates/header.html',
                               {'title': 'Thank you!'})
        html = html + "<p>Thank you for providing your sighting data.</p>"
        html = html + template.render(
            'templates/footer.html',
            {'links': 'Enter <a href="/">another sighting</a>.'})
        self.response.out.write(html)


app = webapp.WSGIApplication([('/.*', SightingInputPage)], debug=True)


def main():
    run_wsgi_app(app)


if __name__ == '__main__':
    main()
Пример #16
0
def main():
    run_wsgi_app(webapp.WSGIApplication([('/.*', Handler)], debug=False))
Пример #17
0
  def help_command(self, message=None):
    message = xmpp.Message(self.request.POST)
    help_msg = "It's not even alpha ready, but you could play with following commands:\n\n" \
               "/hello -> about me\n\n" \
	       "/subscribe <url>\n/unsubscribe <url|'all'> -> subscribe or unsubscribe to a feed\n\n" \
	       "/list <page_index> ->  list subscriptions, default to page 1\n\n" \
	       "/help ->  get help message\n"
    message.reply(help_msg)
    message.reply(message.body)
  
  ##
  # All other commants
  def unhandled_command(self, message=None):
    message = xmpp.Message(self.request.POST)
    message.reply("Please, type /help for help.")
  
  ##
  # Sent for any message.
  def text_message(self, message=None):
    message = xmpp.Message(self.request.POST)
    message.reply("Echooooo (when you're done playing, type /help) > " + message.body)

application = webapp.WSGIApplication([('/_ah/xmpp/message/chat/', XMPPHandler), ('/', MainPage), ('/hubbub/(.*)', HubbubSubscriber)],debug=True)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()
  
Пример #18
0
def main ():
  application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
  util.run_wsgi_app (application)
Пример #19
0
def main():
    application = webapp.WSGIApplication([('/', MainPage)], debug=True)
    run_wsgi_app(application)
Пример #20
0
Here are the votes:
<p />
<img src = "%s" />
</body>
</html>

""" % charturl)


class BeatlesPage(webapp.RequestHandler):
    def get(self):
        user = get_user(self)
        if not user: return
        self.response.out.write("hello, goodbye\n" + "I am the walrus")


application = webapp.WSGIApplication([("/", MainPage),
                                      ("/beatles", BeatlesPage),
                                      ("/quiz", QuizPage),
                                      ("/answer", AnswerPage),
                                      ("/results", ResultsPage)],
                                     debug=True)


def main():
    run_wsgi_app(application)


if __name__ == "__main__":
    main()
Пример #21
0
    def get(self):
        global service
        two_legged_oauth = self.request.get('two_legged_oauth')
        # Revoke the token for 3-legged OAuth
        if two_legged_oauth != 'True':
            try:
                service.RevokeOAuthToken()
            except gdata.service.RevokingOAuthTokenFailed:
                pass
            except gdata.service.NonOAuthToken:
                pass
            finally:
                service.token_store.remove_all_tokens()

        service = None
        self.redirect('/')


application = webapp.WSGIApplication([('/', MainPage), ('/do_auth', DoAuth),
                                      ('/start_over', DoStartOver),
                                      ('/login', DoLogin)],
                                     debug=True)


def main():
    run_wsgi_app(application)


if __name__ == "__main__":
    main()
Пример #22
0
                      title=mailer.permissions_title)

    def post(self):
        self.access_init()
        mailer = FormMailerDecisionMaker(self)
        values = self.request.get_all('user-permissions')
        self.save_permissions(permissions=mailer.permissions,
                              values=values,
                              url=mailer.permissions_url)


app = webapp.WSGIApplication([
    ('/free-photo-session-application/permissions', FormMailerPermissions),
    ('/free-photo-session-application', FormMailer),
    ('/contact/permissions', FormMailerPermissions),
    ('/contact', FormMailer),
    ('/casting/permissions', FormMailerPermissions),
    ('/casting', FormMailer),
],
                             debug=False)
'''def main():
     application = webapp.WSGIApplication(
         [('/free-photo-session-application/permissions', FormMailerPermissions),
          ('/free-photo-session-application', FormMailer),
          ('/contact/permissions', FormMailerPermissions),
          ('/contact', FormMailer),
          ('/casting/permissions', FormMailerPermissions),
          ('/casting', FormMailer),],
         debug=False)
     util.run_wsgi_app(application)
 
Пример #23
0
                "id": None,
                "limit": 1
            }],
            'name':
            None,
            'name|=':
            names,
            "origin": [{
                "name": None,
                "geolocation": [{
                    "latitude": None,
                    "longitude": None
                }]
            }]
        }]
        mqlResult = freebase.mqlread(mqlQuery)
        self.response.out.write(simplejson.dumps(mqlResult))


apps_binding = []
apps_binding.append(('/', MainPage))
apps_binding.append(('/lookup', LookupHandler))
application = webapp.WSGIApplication(apps_binding, debug=True)


def main():
    run_wsgi_app(application)


if __name__ == "__main__":
    main()
    ns = self.request.get('ns')
    namespace_manager.set_namespace(ns)
    self.response.out.write('<html><body>')

    greetings = db.GqlQuery("SELECT * "
                            "FROM Greeting "
                            "ORDER BY date DESC")

    for greeting in greetings:
      self.response.out.write('An anonymous person wrote:')
      self.response.out.write('<blockquote>%s</blockquote>' %
                              cgi.escape(greeting.content))
    end = time.time()
    self.response.out.write("Time Taken: " + str(end - start))

application = webapp.WSGIApplication([
  ('/get', Get),
  ('/put', Put),
  ('/delete', Delete),
  ('/query', Query)
], debug=True)


def main():
  wsgiref.handlers.CGIHandler().run(application)


if __name__ == '__main__':
  main()

Пример #25
0
def main():
    application = webapp.WSGIApplication([
        ('/.*', MainHandler),
    ], debug=True)
    wsgiref.handlers.CGIHandler().run(application)
Пример #26
0
                rp += "<div class='guestname'>" + greeting.author.nickname + "</div>"
            else:
                rp += "<div class='guestname'>An anonymous person</div>"
            content = greeting.content.replace("<",
                                               "&lt;").replace(">", "&gt;")
            rp += "<div class='guestcontent'>" + content + "</div>"
        self.response.out.write(rp)


class MyInformation(webapp.RequestHandler):
    def get(self):
        template_values = {}
        path = os.path.join(os.path.dirname(__file__), 'MyInformation.html')
        self.response.out.write(template.render(path, template_values))


application = webapp.WSGIApplication([('/', MainPage),
                                      ('/GuestBook', GuestBook),
                                      ('/GetGuest', GetGuest),
                                      ('/PutGuestBook', PutGuestBook),
                                      ('/MyInformation', MyInformation)],
                                     debug=True)


def main():
    run_wsgi_app(application)


if __name__ == "__main__":
    main()
Пример #27
0
import jt.service.gameinfo
import logging


class GetAccountsByHighScore(webapp.RequestHandler):
    def get(self):
        accounts = jt.service.gameinfo.getAccountsByHighScore(200)
        self.response.out.write(
            jt.modelhelper.JsonQueryUtil.toArray('accounts', accounts))


class GetLastTenPhotoKeys(webapp.RequestHandler):
    def get(self):
        photoKeys = jt.service.gameinfo.getLastTenPhotoKeys()
        self.response.out.write(
            jt.modelhelper.keyArrayToJson('photoKeys', photoKeys))


application = webapp.WSGIApplication([
    ('/data/game/getAccountsByHighScore', GetAccountsByHighScore),
    ('/data/game/getLastTenPhotos', GetLastTenPhotoKeys),
],
                                     debug=True)


def main():
    run_wsgi_app(application)


if __name__ == "__main__":
    main()
Пример #28
0
def main():
    util.run_wsgi_app(webapp.WSGIApplication([
        (r"/", HomeHandler),
        (r"/auth/login", LoginHandler),
        (r"/auth/logout", LogoutHandler),
    ]))
Пример #29
0

class TagRedirectHandler(webapp.RequestHandler):
    def get(self, root, path):
        dst = "%s%s" % (redirect.tags_dst, path)
        self.redirect(dst, True)  # permanent redirect


class RedirectHandler(webapp.RequestHandler):
    def get(self, path):
        d = redirect.explicit_data
        if path in d.keys():
            dst = d[path]
            self.redirect(dst, True)  # permanent redirect
        else:
            self.error(404)


application = webapp.WSGIApplication(
    [('/', MainPage), (redirect.tags_regex, TagRedirectHandler),
     ('(.*)', RedirectHandler)],
    debug=True)


def main():
    run_wsgi_app(application)


if __name__ == "__main__":
    main()
Пример #30
0
                record.emailAddress,
                "datetime_posted":
                loc_datetime_posted
            }]

        render_page(self, 'signup_list', {
            'title': 'Signups',
            'record_list': record_list,
        })


###########################
##### Utility methods #####
###########################


def render_page(self, pagename, template_values):
    path = os.path.join(os.path.dirname(__file__),
                        'html/' + pagename + '.html')
    self.response.out.write(template.render(path, template_values))


########################
##### Main methods #####
########################

application = webapp.WSGIApplication([('/submit', SubmitPage),
                                      ('/list', List_Signups),
                                      ('/(.*)', MainPage)],
                                     debug=True)