示例#1
0
def main():
  application = webapp.WSGIApplication([(r'/api/tracks/([0-9]{1,64})', TrackIDHandler),
																				('/api/tracks.*', TracksHandler),
																				('/api/locations/maxtracks.*', MaxTracksHandler),
																				(r'/api/locations/([0-9]{1,64})', LocationIDHandler),
																				('/api/locations.*', LocationsHandler)], debug=utils.in_development_enviroment())
  run_wsgi_app(application)
def main():
    application = webapp.WSGIApplication(
        [(r'/backend/cleanup/start', CleanupHandler),
         (r'/backend/cleanup/tracks/([0-9a-zA-Z-_]{1,128})',
          CleanupTrackHandler)],
        debug=utils.in_development_enviroment())
    run_wsgi_app(application)
示例#3
0
def main():
    application = webapp.WSGIApplication(
        [('/playlists', Playlists), ('/playlists/', Playlists),
         ('/playlists/.*', Playlist), ('/pages/flush[/]*', Flush),
         ('/api/.*', API), ('/user', User), ('/share/.*', SharePlaylist),
         ('/', PlayerPage)],
        debug=utils.in_development_enviroment())
    run_wsgi_app(application)
示例#4
0
def main():
    application = webapp.WSGIApplication(
        [(r'/api/tracks/([0-9]{1,64})', TrackIDHandler),
         ('/api/tracks.*', TracksHandler),
         ('/api/locations/maxtracks.*', MaxTracksHandler),
         (r'/api/locations/([0-9]{1,64})', LocationIDHandler),
         ('/api/locations.*', LocationsHandler)],
        debug=utils.in_development_enviroment())
    run_wsgi_app(application)
示例#5
0
    def get(self):

        memcached = memcache.get(self.request.path_qs, namespace='api_cache')
        if memcached is not None and not utils.in_development_enviroment():
            return self.response.out.write(memcached)

        # initialization
        locations_array = []
        genre = self.request.get('genre')
        if self.request.get('limit'):
            limit = int(self.request.get('limit'))
        else:
            limit = settings.FRONTEND_LOCATIONS_LIMIT
        if self.request.get('offset'):
            offset = int(self.request.get('offset'))
        else:
            offset = 0

        # Processing latest locations for a certain genre api/locations/?genre={genre_name}
        if genre and genre != 'all':
            if genre not in utils.genres:
                error_response(
                    self, 'unknown_genre',
                    'Sorry, but we do not know the genre %s.' % genre)
                return
            location_genres = models.LocationGenreLastUpdate.all().order(
                '-last_time_updated').filter('genre',
                                             genre).fetch(limit, offset)
            if location_genres:
                max_tracks = 0
                for location_genre in location_genres:
                    if location_genre.track_counter > max_tracks:
                        max_tracks = location_genre.track_counter
                return memcache_and_output_array(
                    self, {'max_tracks': max_tracks},
                    (settings.MAX_TRACKS_CACHE_TIME - 5))
            else:
                self.response.out.write("[]")  # empty array
            return

        # Processing latest locations for api/locations
        if not genre or genre == 'all':
            locations = models.Location.all().order(
                '-last_time_updated').fetch(limit, offset)
            if locations:
                max_tracks = 0
                for location in locations:
                    if location.track_counter > max_tracks:
                        max_tracks = location.track_counter
                return memcache_and_output_array(
                    self, {'max_tracks': max_tracks},
                    (settings.MAX_TRACKS_CACHE_TIME - 5))
            else:
                self.response.out.write("[]")  # empty array
            return
def main():
  application = webapp.WSGIApplication([
                                      ('/playlists', Playlists), 
                                      ('/playlists/', Playlists), 
                                      ('/playlists/.*', Playlist), 
                                      ('/api/.*', API), 
                                      ('/user', User), 
                                      ('/share/.*', SharePlaylist), 
                                      ('/', PlayerPage)
                                      ], debug=utils.in_development_enviroment())
  run_wsgi_app(application)
示例#7
0
  def get(self, location_id=None):

    memcached = memcache.get(self.request.path_qs, namespace='api_cache' )
    if memcached is not None and not utils.in_development_enviroment():
      return self.response.out.write(memcached)
    
    if location_id:
      return fetch_location_by_id(self, location_id)
    else:
      error_response(self, 'no_location', 'You have provided no location id.')  
    return    
示例#8
0
    def get(self, track_id=None):

        memcached = memcache.get(self.request.path_qs, namespace='api_cache')
        if memcached is not None and not utils.in_development_enviroment():
            return self.response.out.write(memcached)

        if track_id:
            return fetch_track_by_id(self, track_id)
        else:
            error_response(self, 'no_track', 'You have provided no track id.')
        return
示例#9
0
    def get(self):
        google_user = users.get_current_user()
        app_user = utils.get_user(google_user)
        if google_user and not app_user:
            app_user = utils.init_new_user(google_user)

        self.response.out.write(
            template.render(
                'player.html', {
                    'user': app_user,
                    'rando': random.random(),
                    'login_url': users.create_login_url("/"),
                    'logout_url': users.create_logout_url("/"),
                    'in_development_enviroment':
                    utils.in_development_enviroment()
                }))
示例#10
0
  def get(self):

    memcached = memcache.get(self.request.path_qs, namespace='api_cache' )
    if memcached is not None and not utils.in_development_enviroment():
      return self.response.out.write(memcached)

    # initialization
    locations_array = []
    genre = self.request.get('genre')   
    if self.request.get('limit'):
      limit = int(self.request.get('limit'))
    else:
      limit = settings.FRONTEND_LOCATIONS_LIMIT
    if self.request.get('offset'):
      offset = int(self.request.get('offset'))
    else:
      offset = 0

    # Processing latest locations for a certain genre api/locations/?genre={genre_name}
    if genre and genre != 'all':
      if genre not in utils.genres:
        error_response(self, 'unknown_genre', 'Sorry, but we do not know the genre %s.' % genre) 
        return
      location_genres = models.LocationGenreLastUpdate.all().order('-last_time_updated').filter('genre', genre).fetch(limit, offset)
      if location_genres:
        max_tracks = 0
        for location_genre in location_genres:
          if location_genre.track_counter > max_tracks:
            max_tracks = location_genre.track_counter
        return memcache_and_output_array(self, {'max_tracks': max_tracks}, (settings.MAX_TRACKS_CACHE_TIME-5))
      else:
        self.response.out.write("[]") # empty array
      return
    
    # Processing latest locations for api/locations
    if not genre or genre == 'all':
      locations = models.Location.all().order('-last_time_updated').fetch(limit, offset)
      if locations:
        max_tracks = 0
        for location in locations:
          if location.track_counter > max_tracks:
            max_tracks = location.track_counter
        return memcache_and_output_array(self, {'max_tracks': max_tracks}, (settings.MAX_TRACKS_CACHE_TIME-5))
      else:
        self.response.out.write("[]") # empty array
      return
示例#11
0
def main():
    application = webapp.WSGIApplication(
        [('/', MainHandler)], debug=utils.in_development_enviroment())
    run_wsgi_app(application)
示例#12
0
 def get(self):
   google_user = users.get_current_user()
   app_user = utils.get_current_user()
   if google_user and not app_user:
     app_user = utils.init_new_user(google_user)
   
   self.response.out.write(template.render('player.html', {'user':app_user,'rando': random.random(), 'login_url': users.create_login_url("/"), 'logout_url':users.create_logout_url("/"), 'in_development_enviroment':utils.in_development_enviroment()}))
示例#13
0
 def get(self):
                                             
   memcached = memcache.get(self.request.path_qs, namespace='api_cache' )
   if memcached is not None and not utils.in_development_enviroment():
     return self.response.out.write(memcached)
                         
   # initializing
   track_array = []
   if self.request.get('limit'):
     limit = int(self.request.get('limit'))
   else:
     limit = settings.FRONTEND_LOCATIONS_LIMIT          
   if self.request.get('offset'):
     offset = int(self.request.get('offset'))
   else:
     offset = 0
   
   # Processing for api/tracks/?track=track_id
   if self.request.get('track'):
     return fetch_track_by_id(self, self.request.get('track'))
   
   # Processing for api/tracks/?genre={genre_name} 
   if self.request.get('genre') and self.request.get('genre') != 'all' and not \
      (self.request.get('location') or self.request.get('location_lat') or self.request.get('location_lon')):
     genre = self.request.get('genre')
     if genre not in utils.genres:
       error_response(self, 'unknown_genre', 'Sorry, but we do not know the genre %s.' % genre) 
       return
     else:
       tracks = models.Track.all().filter('genre IN', utils.genres.get(genre)).order('-created_at').fetch(limit, offset)
       if tracks:                           
         for track in tracks:
           add_to_track_array(track, track_array)
         return memcache_and_output_array(self, track_array, utils.genres.get(genre)[0])
       else:
         self.response.out.write("[]") # empty array
       return           
   
   # Processing for api/tracks/?location=location_id
   if self.request.get('location') and (self.request.get('genre') == 'all' or not self.request.get('genre')): 
     location = models.Location.get_by_id(int(self.request.get('location')))
     if not location:
       error_response(self, 'location_not_found', 'The location with the id %s is not in the datastore.' % self.request.get('location'))
     else:
       tracks = models.Track.all().filter('location', location.key()).order('-created_at').fetch(limit, offset)
       if tracks:
         for track in tracks:
           add_to_track_array(track, track_array)              
         return memcache_and_output_array(self, track_array, location.city)
       else:
         self.response.out.write("[]") # empty array
     return
     
   # Processing for api/tracks/?location=location_id&genre={genre_name}  
   if self.request.get('location') and self.request.get('genre'):
     genre = self.request.get('genre')
     if genre not in utils.genres:
       error_response(self, 'unknown_genre', 'Sorry, but we do not know the genre %s.' % genre) 
       return
     location = models.Location.get_by_id(int(self.request.get('location')))
     if not location:
       error_response(self, 'location_not_found', 'The location with the id %s is not in the datastore.' % self.request.get('location'))
       return
     else:
       tracks = models.Track.all().filter('location', location.key()).filter('genre IN', utils.genres.get(genre))
       tracks = tracks.order('-created_at').fetch(limit, offset)
       if tracks:
         for track in tracks:
           add_to_track_array(track, track_array)              
         return memcache_and_output_array(self, track_array, (location.city + "_" + utils.genres.get(genre)[0]))
       else:
         self.response.out.write("[]") # empty array
     return
     
   # Processing for api/tracks and api/tracks/?genre=all
   if (self.request.get('genre') == 'all' or not self.request.get('genre')) and not \
      (self.request.get('location') or self.request.get('location_lat') or self.request.get('location_lon')): 
     tracks = models.Track.all().order('-created_at').fetch(limit, offset)
     if tracks:                           
       for track in tracks:
         add_to_track_array(track, track_array)
       return memcache_and_output_array(self, track_array)
     else:
       self.response.out.write("[]") # empty array
     return      
示例#14
0
def main():
  application = webapp.WSGIApplication([('/', MainHandler)], debug=utils.in_development_enviroment())
  run_wsgi_app(application)
示例#15
0
def main():
  application = webapp.WSGIApplication([
    (r'/backend/cleanup/start', CleanupHandler),
    (r'/backend/cleanup/tracks/([0-9a-zA-Z-_]{1,128})', CleanupTrackHandler)
    ], debug=utils.in_development_enviroment())
  run_wsgi_app(application)
示例#16
0
    def get(self):

        memcached = memcache.get(self.request.path_qs, namespace='api_cache')
        if memcached is not None and not utils.in_development_enviroment():
            return self.response.out.write(memcached)

        # initializing
        track_array = []
        if self.request.get('limit'):
            limit = int(self.request.get('limit'))
        else:
            limit = settings.FRONTEND_LOCATIONS_LIMIT
        if self.request.get('offset'):
            offset = int(self.request.get('offset'))
        else:
            offset = 0

        # Processing for api/tracks/?track=track_id
        if self.request.get('track'):
            return fetch_track_by_id(self, self.request.get('track'))

        # Processing for api/tracks/?genre={genre_name}
        if self.request.get('genre') and self.request.get('genre') != 'all' and not \
           (self.request.get('location') or self.request.get('location_lat') or self.request.get('location_lon')):
            genre = self.request.get('genre')
            if genre not in utils.genres:
                error_response(
                    self, 'unknown_genre',
                    'Sorry, but we do not know the genre %s.' % genre)
                return
            else:
                tracks = models.Track.all().filter(
                    'genre IN',
                    utils.genres.get(genre)).order('-created_at').fetch(
                        limit, offset)
                if tracks:
                    for track in tracks:
                        add_to_track_array(track, track_array)
                    return memcache_and_output_array(
                        self, track_array,
                        utils.genres.get(genre)[0])
                else:
                    self.response.out.write("[]")  # empty array
                return

        # Processing for api/tracks/?location=location_id
        if self.request.get('location') and (self.request.get('genre') == 'all'
                                             or not self.request.get('genre')):
            location = models.Location.get_by_id(
                int(self.request.get('location')))
            if not location:
                error_response(
                    self, 'location_not_found',
                    'The location with the id %s is not in the datastore.' %
                    self.request.get('location'))
            else:
                tracks = models.Track.all().filter(
                    'location',
                    location.key()).order('-created_at').fetch(limit, offset)
                if tracks:
                    for track in tracks:
                        add_to_track_array(track, track_array)
                    return memcache_and_output_array(self, track_array,
                                                     location.city)
                else:
                    self.response.out.write("[]")  # empty array
            return

        # Processing for api/tracks/?location=location_id&genre={genre_name}
        if self.request.get('location') and self.request.get('genre'):
            genre = self.request.get('genre')
            if genre not in utils.genres:
                error_response(
                    self, 'unknown_genre',
                    'Sorry, but we do not know the genre %s.' % genre)
                return
            location = models.Location.get_by_id(
                int(self.request.get('location')))
            if not location:
                error_response(
                    self, 'location_not_found',
                    'The location with the id %s is not in the datastore.' %
                    self.request.get('location'))
                return
            else:
                tracks = models.Track.all().filter('location',
                                                   location.key()).filter(
                                                       'genre IN',
                                                       utils.genres.get(genre))
                tracks = tracks.order('-created_at').fetch(limit, offset)
                if tracks:
                    for track in tracks:
                        add_to_track_array(track, track_array)
                    return memcache_and_output_array(
                        self, track_array,
                        (location.city + "_" + utils.genres.get(genre)[0]))
                else:
                    self.response.out.write("[]")  # empty array
            return

        # Processing for api/tracks and api/tracks/?genre=all
        if (self.request.get('genre') == 'all' or not self.request.get('genre')) and not \
           (self.request.get('location') or self.request.get('location_lat') or self.request.get('location_lon')):
            tracks = models.Track.all().order('-created_at').fetch(
                limit, offset)
            if tracks:
                for track in tracks:
                    add_to_track_array(track, track_array)
                return memcache_and_output_array(self, track_array)
            else:
                self.response.out.write("[]")  # empty array
            return