예제 #1
0
파일: main.py 프로젝트: jameesjohn/oppia
def get_redirect_route(
        regex_route: str,
        handler: Type[base.BaseHandler],
        defaults: Optional[Dict[str, str]] = None) -> routes.RedirectRoute:
    """Returns a route that redirects /foo/ to /foo.

    Warning: this method strips off parameters after the trailing slash. URLs
    with parameters should be formulated without the trailing slash.

    Args:
        regex_route: unicode. A raw string representing a route.
        handler: BaseHandler. A callable to handle the route.
        defaults: dict. Optional defaults parameter to be passed
            into the RedirectRoute object.

    Returns:
        RedirectRoute. A RedirectRoute object for redirects.
    """
    if defaults is None:
        defaults = {}
    name = regex_route.replace('/', '_')
    return routes.RedirectRoute(regex_route,
                                handler,
                                name,
                                strict_slash=True,
                                defaults=defaults)
예제 #2
0
파일: main.py 프로젝트: singhankit03/oppia
def get_redirect_route(regex_route, handler, defaults=None):
    """Returns a route that redirects /foo/ to /foo.

    Warning: this method strips off parameters after the trailing slash. URLs
    with parameters should be formulated without the trailing slash.
    """
    if defaults is None:
        defaults = {}
    name = regex_route.replace('/', '_')
    return routes.RedirectRoute(
        regex_route, handler, name, strict_slash=True, defaults=defaults)
예제 #3
0
파일: main.py 프로젝트: navotgil/airports
        template = J_E.get_template('/html/index.html')
        self.response.write(template.render({"version":"001"}))

class CreateDB(webapp2.RequestHandler):
    def get(self):
        counter = utils.createDbFromCSV('large_airports.csv')
        self.response.write("Added " + str(counter) + " airports")

class Airports(webapp2.RequestHandler):
    def get(self):
        template = J_E.get_template('/html/airports.html')
        airports = utils.db.getAllAirports()
        contex = {}
        contex["airports"] = airports
        self.response.write(template.render(contex))

class AirportPage(webapp2.RequestHandler):
    def get(self, ident):
        template = J_E.get_template('/html/airport.html')
        airport = utils.db.getAirport(ident)
        contex = {}
        contex["airport"] = airport
        self.response.write(template.render(contex))

app = webapp2.WSGIApplication([
    routes.RedirectRoute('/', handler=MainHandler, name='main', strict_slash=True),
    routes.RedirectRoute('/airports', handler=Airports, name='airports', strict_slash=True),
    routes.RedirectRoute('/airports/<ident>', handler=AirportPage, name='airport', strict_slash=True),
    routes.RedirectRoute('/create_db', handler=CreateDB, name='create_db', strict_slash=True)
], debug=True)
예제 #4
0
#!/usr/bin/env python
import webapp2

from webapp2_extras import routes

URL_MAPPING = [
    routes.RedirectRoute('/',
                         redirect_to='https://www.meetup.com/gdglondon',
                         name='GDG London',
                         strict_slash=True)
]

APP = webapp2.WSGIApplication(URL_MAPPING, debug=False)
예제 #5
0
def redirect(url, to, app_router=None):
    """
    Adds a redirect route with the given url templates.
    """
    add(routes.RedirectRoute(url, redirect_to=to), app_router)
예제 #6
0
# Batch processing task URL routes
# These should not be configured to be public, but only
# available through private backends, requiring admin login.
import webapp2
from config import config
from webapp2_extras import routes

urls = [
    routes.RedirectRoute(r'/tasks/twitter',
                         handler='task_handlers.TwitterTaskHandler',
                         strict_slash=True,
                         name='twitter-task'),
]

app = webapp2.WSGIApplication(urls, config=config.config, debug=True)
예제 #7
0
파일: main.py 프로젝트: DanSamama/Atomical
            #     if originalPrev:
            #         originalPrev.next = None
            #         originalPrev.put()
            #
            # else:
            #     pass
            #     #console.log("i was not last");


class DeleteActivity(webapp2.RequestHandler):
    def get(self):
        currentActivityid = self.request.get("currentActivity")

        db.deleteActivityFromRepository(currentActivityid)


app = webapp2.WSGIApplication([
    ('/', MainHandler),
    ('/stone', StoneForm),
    ('/activity', ActivityForm),
    ('/schedule_activity', ScheduleActivity),
    ('/update_schedule_activity', updateScheduleActivity),
    ('/delete_activity', DeleteActivity),
    ('/create_db', CreateDb),
    routes.RedirectRoute('/repository/<program>/<cohort>',
                         handler=ChronoList,
                         name='chronolist',
                         strict_slash=True),
],
                              debug=True)
예제 #8
0
import webapp2
import configuration

from webapp2_extras import routes

application = webapp2.WSGIApplication([
    webapp2.Route('/',
                  handler='home.Home',
                  name='home'),
    # Manga endpoints
    routes.RedirectRoute('/manga',
                         handler='manga.Manga',
                         name='manga-add',
                         strict_slash=True),
    routes.PathPrefixRoute('/manga', [
        routes.RedirectRoute('/list',
                             handler='manga.MangaList',
                             name='manga-list',
                             strict_slash=True),
        routes.RedirectRoute('/<ident>',
                             handler='manga.Manga',
                             name='manga-edit',
                             strict_slash=True),
        routes.RedirectRoute('/delete/<ident>',
                             handler='manga.MangaDelete',
                             name='manga-delete',
                             strict_slash=True),
        routes.RedirectRoute('/update/<ident>',
                             handler='update.UpdateOne',
                             name='manga-update',
                             strict_slash=True),
예제 #9
0
#    Copyright 2013 Google Inc
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

"""  A simple handler which redirects the root URL of this app to the UI folder
"""
import webapp2
from webapp2_extras import routes

app = webapp2.WSGIApplication([
    routes.RedirectRoute(r'/', redirect_to='/ui/index.html'),
    routes.RedirectRoute(r'/ui', redirect_to='/ui/index.html'),
    routes.RedirectRoute(r'/ui/', redirect_to='/ui/index.html'),
]);

예제 #10
0
        # to be enabled in some future version, experimental: webapp2.Route(r'/keytest', handler=appkey_handlers.AppKeyTestHandler),

        #
        # workers/status
        #
        routes.PathPrefixRoute('/workers', [
            webapp2.Route(r'/all/status', handler=worker_handlers.Workers_all_status_handler),
            webapp2.Route(r'/<guid>/status', handler=worker_handlers.Workers_status_handler),
            webapp2.Route(r'/<guid>/sys_health', handler=worker_handlers.Workers_sys_health_handler),
            webapp2.Route(r'/<guid>/log', handler=worker_handlers.Workers_log_handler),
        ]),

        #
        # topic/task queue access
        #
        routes.RedirectRoute(r'/topics', handler=topic_task_handlers.TopicCollectionHandler, strict_slash=True, name='Topipcs'),
        routes.PathPrefixRoute('/topics', [
            
            routes.RedirectRoute(r'/<topic_name>', handler=topic_task_handlers.TopicHandler, strict_slash=True, name='Topic'),
            
            webapp2.Route(r'/<topic_name>/num_recent_tasks', handler=topic_task_handlers.TaskStatsReporterHandler_num_recent_tasks_created),
            webapp2.Route(r'/<topic_name>/num_creatable_tasks', handler=topic_task_handlers.TopicHandler_num_creatable_tasks),
            webapp2.Route(r'/<topic_name>/max_num_tasks', handler=topic_task_handlers.TopicHandler_max_num_tasks),
            routes.RedirectRoute(r'/<topic_name>/offers', handler=topic_task_handlers.AssignTaskHandler, strict_slash=True, name='Topic_offers'),
            routes.RedirectRoute(r'/<topic_name>/tasks', handler=topic_task_handlers.TaskCollectionHandler, strict_slash=True, name='Topic_tasks'),
            routes.RedirectRoute(r'/<topic_name>/rejected_tasks', handler=topic_task_handlers.RejectedTaskCollectionHandler, strict_slash=True, name='Topic_rejected_tasks'),
            routes.RedirectRoute(r'/<topic_name>/rejected_tasks/count', handler=topic_task_handlers.RejectedTaskCountHandler, strict_slash=True, name='Topic_rejected_tasks_count'),
            routes.RedirectRoute(r'/<topic_name>/waiting_tasks', handler=topic_task_handlers.WaitingTaskCollectionHandler, strict_slash=True, name='Topic_waiting_tasks'),
            routes.RedirectRoute(r'/<topic_name>/waiting_tasks/count', handler=topic_task_handlers.WaitingTaskCountHandler, strict_slash=True, name='Topic_waiting_tasks_count'),
            routes.RedirectRoute(r'/<topic_name>/working_tasks', handler=topic_task_handlers.WorkingTaskCollectionHandler, strict_slash=True, name='Topic_working_tasks'),
            routes.RedirectRoute(r'/<topic_name>/working_tasks/count', handler=topic_task_handlers.WorkingTaskCountHandler, strict_slash=True, name='Topic_working_tasks_count'),