示例#1
0
    def decorator(fn):
        @wraps(fn)
        def decorated_view(*args, **kwargs):
            app.logger.debug("API: %s.%s" % (fn.__module__, fn.__name__))
            # TODO: login_required
            return fn(*args, **kwargs)

        api_rule = app.config['API_PREFIX'] + rule
        endpoint = options.pop('endpoint', api_rule)
        app.add_url_rule(api_rule, endpoint, view_func=decorated_view, **options)
        return decorated_view
示例#2
0
    def decorator(fn):
        @wraps(fn)
        def decorated_view(*args, **kwargs):
            app.logger.debug("API: %s.%s" % (fn.__module__, fn.__name__))
            # TODO: login_required
            return fn(*args, **kwargs)

        api_rule = app.config['API_PREFIX'] + rule
        endpoint = options.pop('endpoint', api_rule)
        app.add_url_rule(api_rule,
                         endpoint,
                         view_func=decorated_view,
                         **options)
        return decorated_view
    def setUp(self):
        # do the normal setUp
        super(LoginTestCase, self).setUp()

        app.config['TESTING'] = True
        app.config['CSRF_ENABLED'] = False

        # Setup a test view
        @login_required
        def secret():
            """Temporary secret page"""
            return "Shhh! It's a secret!"

        # add the test view
        self.secret = secret
        app.add_url_rule('/secretTest', 'secret', self.secret)

        # redo the test client
        self.app = app.test_client()

        # make the fake users
        self.users = create_test_users()
示例#4
0
    def setUp(self):
        # do the normal setUp
        super(LoginTestCase, self).setUp()

        app.config['TESTING'] = True
        app.config['CSRF_ENABLED'] = False

        # Setup a test view
        @login_required
        def secret():
            """Temporary secret page"""
            return "Shhh! It's a secret!"

        # add the test view
        self.secret = secret
        app.add_url_rule('/secretTest', 'secret', self.secret)

        # redo the test client
        self.app = app.test_client()

        # make the fake users
        self.users = create_test_users()
示例#5
0
def register_application_web_route(view, endpoint, url, view_args={}, pk='id',
                                   pk_type='int'):
    view_func = view.as_view(endpoint, **view_args)
    app.add_url_rule(url, defaults={pk: None}, view_func=view_func,
        methods=['GET',])
    app.add_url_rule(url, view_func=view_func, methods=['POST',])
    app.add_url_rule('%s<%s:%s>' % (url, pk_type, pk), view_func=view_func,
        methods=['GET', 'POST'])
示例#6
0
 def __init__(self, app, module):
   super(TableView, self).__init__()
   self.__module__ = module
   self.__name__ = self.__module__["base"]["name"]
   app.add_url_rule('/%s'%self.__name__, view_func = self, methods=['GET'])
   if self.__module__.get("actions", {}):
     app.add_url_rule('/%s/<action>'%self.__name__, view_func = self, methods=['GET', 'POST'])
     app.add_url_rule('/%s/<action>/<_id>'%self.__name__, view_func = self, methods=['GET', 'POST'])
示例#7
0
文件: urls.py 项目: slowcall/lo9
urls.py

URL dispatch route mappings and error handlers

"""

from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# News Post
app.add_url_rule('/post', 'news_post', view_func=views.news_post, methods=['GET', 'POST'])

# redirect
app.add_url_rule('/<int:post_id>', 'redirect_url', view_func=views.redirect_url, methods=['GET'])

# comment
app.add_url_rule('/<int:post_id>/c', 'comment', view_func=views.comment, methods=['GET'])

# hot switch
app.add_url_rule('/hot/<int:post_id>', 'hot', view_func=views.hot, methods=['GET'])

# bookmarklet
app.add_url_rule('/bookmarklet', 'bookmarklet', view_func=views.bookmarklet)
示例#8
0
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views

## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# Stream list page
app.add_url_rule('/stream',
                 'list_streams',
                 view_func=views.list_streams,
                 methods=['GET', 'POST'])

# Stream show page
app.add_url_rule('/stream/<int:stream_id>',
                 'show_stream',
                 view_func=views.show_stream,
                 methods=['GET'])
示例#9
0
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# Say hello
app.add_url_rule('/hello/<username>', 'say_hello', view_func=views.say_hello)

# Examples list page
app.add_url_rule('/examples', 'list_examples', view_func=views.list_examples, methods=['GET', 'POST'])

# Examples list page (cached)
app.add_url_rule('/examples/cached', 'cached_examples', view_func=views.cached_examples, methods=['GET'])

# Contrived admin-only view example
app.add_url_rule('/admin_only', 'admin_only', view_func=views.admin_only)
示例#10
0
URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views

## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
# app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'index', view_func=views.index)

# # Say hello
# app.add_url_rule('/hello/<username>', 'say_hello', view_func=views.say_hello)

# # Examples list page
# app.add_url_rule('/examples', 'list_examples', view_func=views.list_examples, methods=['GET', 'POST'])

# # Examples list page (cached)
# app.add_url_rule('/examples/cached', 'cached_examples', view_func=views.cached_examples, methods=['GET'])

# # Contrived admin-only view example
# app.add_url_rule('/admin_only', 'admin_only', view_func=views.admin_only)

# # Edit an example
# app.add_url_rule('/examples/<int:example_id>/edit', 'edit_example', view_func=views.edit_example, methods=['GET', 'POST'])
示例#11
0
from controllers.AuthController import login, logout
from controllers.UserController import UserAPI
from controllers.TripController import TripAPI, CreateTripAPI
from controllers.WaypointController import WaypointAPI, CreateWaypointAPI
from controllers.TripWaypointController import TripWaypointAPI, TripWaypointListAPI, TripWaypointDeleteAPI
from controllers.UserTripController import UserTripAPI, UserTripListAPI, UserTripDeleteAPI

# Allow cross domain requests from localhost
CORS(app, resources={r"/api/*": {"origins": "http://localhost:1234"}})

# # API Endpoints
api = Api(app)

# Home page and login/logout
app.add_url_rule("/", "public_index", view_func=PublicIndex.as_view("public_index"))
app.add_url_rule("/login", "login", view_func=login)
app.add_url_rule("/logout", "logout", view_func=logout)

# RESTful API
# TODO: figure out if email can be used as key without duplicates due to
# default values
# api.add_resource(UserAPI, '/api/users/<string:id>')
api.add_resource(UserAPI, "/api/user/<string:id>")
api.add_resource(UserTripListAPI, "/api/user/trip/list/<string:user_id>")
api.add_resource(UserTripAPI, "/api/user/trip/<string:user_id>")

api.add_resource(TripAPI, "/api/trip/<int:id>")
api.add_resource(CreateTripAPI, "/api/trip/new")
api.add_resource(TripWaypointListAPI, "/api/trip/waypoint/list/<int:trip_id>")
api.add_resource(TripWaypointAPI, "/api/trip/waypoint/<int:trip_id>")
示例#12
0
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# Stream list page
app.add_url_rule('/stream', 'list_streams', view_func=views.list_streams, methods=['GET', 'POST'])

# Stream show page
app.add_url_rule('/stream/<int:stream_id>', 'show_stream', view_func=views.show_stream, methods=['GET'])

# Edit a stream
app.add_url_rule('/stream/<int:stream_id>/edit', 'edit_stream', view_func=views.edit_stream, methods=['GET', 'POST'])

# Delete a stream
app.add_url_rule('/stream/<int:stream_id>/delete', view_func=views.delete_stream, methods=['POST'])
示例#13
0
urls.py

URL dispatch route mappings and error handlers

"""

from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/?page=<page>', 'main', view_func=views.main)
app.add_url_rule('/', 'main', view_func=views.main)

# Contrived admin-only view example
app.add_url_rule('/admin_only', 'admin_only', view_func=views.admin_only)

# Add new lie
app.add_url_rule('/new', 'new_lie', view_func=views.new_lie, methods=['GET', 'POST'])

## Error handlers
# Handle 404 errors
@app.errorhandler(404)
def page_not_found(e):
示例#14
0
import logging

from graphql_server.flask import GraphQLView

from api import schema
from application import app
from views.authentication import get_tokens, logout, steam_login
from views.redirect import redirect_view
from views.sitemap import sitemap_view
from views.teams import teams_view

logging.basicConfig(level=logging.INFO)

try:
    app.add_url_rule("/graphql",
                     view_func=GraphQLView.as_view(
                         "graphql",
                         schema=schema.graphql_schema,
                         graphiql=True))
    app.add_url_rule("/redirect/<provider>/<skin_id>/",
                     view_func=redirect_view)
    app.add_url_rule("/sitemap.xml", view_func=sitemap_view, methods=["GET"])
    app.add_url_rule("/teams.json", view_func=teams_view, methods=["GET"])
    app.add_url_rule("/steam/login", view_func=steam_login)
    app.add_url_rule("/rest/jwt/", view_func=get_tokens, methods=["POST"])
    app.add_url_rule("/rest/jwt/", view_func=logout, methods=["DELETE"])
except AssertionError:
    pass

import commands  # noqa
示例#15
0
__author__ = 'fernando'
from application import app, API_PREFIX
from application import controllers

app.add_url_rule('/', 'index', view_func=controllers.main)
app.add_url_rule(API_PREFIX + '/coto/<int:coto_id>/ultimaactividad',
                 'ultimaactividad',
                 view_func=controllers.ultima_actividad)
from application import app
from application import views

# Home page
app.add_url_rule('/', 'home', view_func=views.home)


@app.errorhandler(404)
def page_not_found(e):
    """Return a custom 404 error."""
    return 'Sorry, Nothing at this URL.', 404


@app.errorhandler(500)
def unexpected_error(e):
    """Return a custom 500 error."""
    return 'Sorry, unexpected error: {}'.format(e), 500
示例#17
0
from application import app
from application import views

# App Engine warm up handler
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# index page
app.add_url_rule('/', 'index', view_func=views.index)

# generate a uuid
app.add_url_rule('/post_data',
                 'post_data',
                 view_func=views.post_data,
                 methods=['POST'])

# display plot
app.add_url_rule('/display/<int:id>', 'display', view_func=views.display)

# save plot
app.add_url_rule('/save/<int:id>', 'save', view_func=views.save)

# remove unsaved figures that are older than 6 hours
app.add_url_rule('/tasks/remove_unsaved',
                 'remove_unsaved',
                 view_func=views.remove_unsaved)

# get d3params
app.add_url_rule('/get_params/<int:id>',
                 'get_params',
                 view_func=views.get_params)
示例#18
0
文件: urls.py 项目: mdamien/ponysynth
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# Songs list page
app.add_url_rule('/songs', 'list_songs', view_func=views.list_songs, methods=['GET', 'POST'])

# Edit a song
app.add_url_rule('/songs/<int:song_id>/edit', 'edit_song', view_func=views.edit_song, methods=['GET', 'POST'])

# Delete a song
app.add_url_rule('/songs/<int:song_id>/delete', view_func=views.delete_song, methods=['POST'])

# Generate the song file
app.add_url_rule('/songs/<int:song_id>.wav', view_func=views.generate_song, methods=['GET'])
示例#19
0
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views

## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# Say hello
app.add_url_rule('/hello/<username>', 'say_hello', view_func=views.say_hello)

# Examples list page
#app.add_url_rule('/examples', 'list_examples', view_func=views.list_examples, methods=['GET', 'POST'])

# Examples list page (cached)
#app.add_url_rule('/examples/cached', 'cached_examples', view_func=views.cached_examples, methods=['GET'])

# Contrived admin-only view example
app.add_url_rule('/admin_only', 'admin_only', view_func=views.admin_only)
示例#20
0
from application import app
from handlers.account_handler import *
from handlers.document_handler import *
from handlers.settings_handler import *
from handlers.web_service_handler import *


# Home
app.add_url_rule("/", "crash_group_home", view_func=document_view, methods=["GET"])

# Login
app.add_url_rule("/login", "login", view_func=login_page, methods=["GET"])

# Settings
app.add_url_rule("/settings", "settings_apps_home", view_func=redirect_to_application, methods=["GET"])
app.add_url_rule("/settings/profile", "settings_profile", view_func=profile, methods=["GET"])
app.add_url_rule("/settings/profile", "settings_profile_put", view_func=profile_update, methods=["PUT"])

# Applications
app.add_url_rule("/settings/applications", "settings_apps", view_func=applications, methods=["GET"])
app.add_url_rule("/settings/applications", "settings_apps_post", view_func=application_add, methods=["POST"])
app.add_url_rule(
    "/settings/applications/<application_id>", "settings_apps_put", view_func=application_update, methods=["PUT"]
)
app.add_url_rule(
    "/settings/applications/<application_id>", "settings_apps_delete", view_func=application_delete, methods=["DELETE"]
)
app.add_url_rule(
    "/settings/applications/<application_id>/invite",
    "settings_apps_invite",
    view_func=application_invite,
示例#21
0
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views

# URL dispatch rules
# App Engine warm up handler
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# About Page
app.add_url_rule('/about', 'about', view_func=views.about)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# Login Page
app.add_url_rule('/login',
                 'login',
                 view_func=views.login,
                 methods=['GET', 'POST'])

# Logout
app.add_url_rule('/logout', 'logout', view_func=views.logout)

# Survey Page
示例#22
0
文件: urls.py 项目: wandp/song-a-day
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# edit comments
app.add_url_rule('/comment/edit/<int:comment_id>', view_func=views.edit_comment)

# Say hello
app.add_url_rule('/hello/<username>', 'say_hello', view_func=views.say_hello)

# songs list page
app.add_url_rule('/songs', 'list_songs', view_func=views.list_songs, methods=['GET', 'POST'])

# songs list page (cached)
app.add_url_rule('/songs/cached', 'cached_songs', view_func=views.cached_songs, methods=['GET'])
示例#23
0
import json
from application import app
from application.models.frequenciaDAO import frequenciaDAO
from application.views.FrequenciaView import FrequenciaView, ListaView
from application.views.SocioView import SocioView
from application.views.UsuarioView import UsuarioView

frequencia_view = FrequenciaView.as_view('frequencia_view')

app.add_url_rule('/frequencia/',
                 view_func=frequencia_view,
                 methods=['GET', 'POST'])
app.add_url_rule('/frequencia/<int:id>',
                 view_func=frequencia_view,
                 methods=['GET', 'PUT'])

lista_view = ListaView.as_view('lista_view')

app.add_url_rule('/lista/', view_func=lista_view, methods=['GET', 'POST'])
app.add_url_rule('/lista/<int:id>',
                 view_func=lista_view,
                 methods=['GET', 'PUT'])

socio_view = SocioView.as_view('socio_view')

app.add_url_rule('/socio/', view_func=socio_view, methods=['GET'])
app.add_url_rule('/socio/<int:id>', view_func=socio_view, methods=['GET'])

usuario_view = UsuarioView.as_view('usuario_view')

app.add_url_rule('/usuario/', view_func=usuario_view, methods=['GET', 'POST'])
示例#24
0
from flask import render_template

# -*- local import -*-
from application import (
    app,
    tasks,
    views,
)
from application.constants import (
    POST_ONLY, )

# URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/
# appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# url to render partials required by angular app
app.add_url_rule('/partials/<path>',
                 'render_partials',
                 view_func=views.render_partials)
app.add_url_rule('/partials/<folder>/<path>',
                 'render_partials',
                 view_func=views.render_partials)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# url to add twitter task
app.add_url_rule('/admin/tweet/fetch',
                 'fetch_tweets',
示例#25
0
from application.views.public.public_warmup import PublicWarmup
from application.views.public.public_index import PublicIndex
from application.views.public.public_say_hello import PublicSayHello

from application.views.admin.admin_list_examples import AdminListExamples
from application.views.admin.admin_list_examples_cached import AdminListExamplesCached
from application.views.admin.admin_secret import AdminSecret
from application.views.admin.admin_edit_example import AdminEditExample
from application.views.admin.admin_delete_example import AdminDeleteExample


# URL dispatch rules

# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'public_warmup', view_func=PublicWarmup.as_view('public_warmup'))

app.add_url_rule('/', 'public_index', view_func=PublicIndex.as_view('public_index'))

app.add_url_rule('/hello/<username>', 'public_say_hello', view_func=PublicSayHello.as_view('public_say_hello'))

app.add_url_rule('/examples', 'list_examples', view_func=AdminListExamples.as_view('list_examples'), methods=['GET', 'POST'])

app.add_url_rule('/examples/cached', 'cached_examples', view_func=AdminListExamplesCached.as_view('cached_examples'))

app.add_url_rule('/admin_only', 'admin_only', view_func=AdminSecret.as_view('admin_only'))

app.add_url_rule('/examples/<int:example_id>/edit', 'edit_example', view_func=AdminEditExample.as_view('edit_example'), methods=['GET', 'POST'])

app.add_url_rule('/examples/<int:example_id>/delete', 'delete_example', view_func=AdminDeleteExample.as_view('delete_example'), methods=['POST'])
示例#26
0
"""
urls.py

URL dispatch route mappings and error handlers

"""
from lib.flask import render_template

from application import app
from application import views


# URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# Detailed post
app.add_url_rule('/post/<int:pid>', 'post_detailed', view_func=views.post_detailed)

# Say hello
app.add_url_rule('/hello/<username>', 'say_hello', view_func=views.say_hello)

# Contrived admin-only view example
app.add_url_rule('/admin_only', 'admin_only', view_func=views.admin_only)


app.add_url_rule('/admin_only/post/add/', 'add_post', methods=['GET', 'POST'],  view_func=views.add_post)
示例#27
0
from application import app, db, bcrypt, login_manager, word_scores
from utils import render_template, user_loader

from twitter_explorer.handlers import login, index, config


login_manager.login_view = 'login'
login_manager.user_loader(user_loader)


# Routes.
app.add_url_rule('/login', 'login', login.login, methods=['GET', 'POST'])
app.add_url_rule('/signup', 'signup', login.register, methods=['GET', 'POST'])
app.add_url_rule('/logout', 'logout', login.logout, methods=['GET'])
app.add_url_rule('/config', 'config', config.config, methods=['GET', 'POST'])
app.add_url_rule('/', 'index', index.index, methods=['GET', 'POST'])


# Debug only.
if __name__ == '__main__':
    host = app.config.get('HOST', '127.0.0.1')
    port = app.config.get('PORT', 5000)
    app.run(host=host, port=port, debug=True)
示例#28
0
from application import app
from handlers.home_handler import *
from handlers.account_handler import *
from handlers.posts_handler import *


# Home
app.add_url_rule('/', 'home', view_func=home, methods=['GET'])

# Login
app.add_url_rule('/login', 'login', view_func=login_page, methods=['GET'])

# Board
app.add_url_rule('/posts', 'posts', view_func=posts, methods=['GET'])
app.add_url_rule('/posts', 'posts_add', view_func=post_add, methods=['POST'])
app.add_url_rule('/posts/<post_id>', 'posts_delete', view_func=post_delete, methods=['DELETE'])

示例#29
0
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views

## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# main
app.add_url_rule('/match',
                 'match',
                 view_func=views.match,
                 methods=['GET', 'POST'])


## Error handlers
# Handle 404 errors
@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404
示例#30
0
urls.py

URL dispatch route mappings and error handlers

"""

from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# Home page
app.add_url_rule('/home', 'home', view_func=views.home)

# About Us page
app.add_url_rule('/about', 'about', view_func=views.about)

# advertise page
app.add_url_rule('/advertise', 'our_adnetwork', view_func=views.our_adnetwork)

# advertise/media_kit page
app.add_url_rule('/mediakit', 'mediakit', view_func=views.media_kit)
示例#31
0
文件: views.py 项目: Solejzi/Fridge
        pass


class FridgeView(MView):
    def __init__(self):
        super().__init__()
        self.template = 'fridge.html'
        self.objects = {'items': db.session.query(InFridge).all()}

    def get(self):
        # shows items in fridge
        pass

    def post(self):
        # adds item to fridge
        pass

    def put(self):
        # opens item
        pass

    def delete(self):
        # deletes item
        pass


app.add_url_rule('/fridge',
                 methods=['GET', 'POST'],
                 view_func=FridgeView.as_view('fridge_view'))
app.add_url_rule('/navigation', view_func=Welcome.as_view('welcome_view'))
from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)
app.add_url_rule('/source/<source>/', 'home', view_func=views.home)
app.add_url_rule('/source/<source>/<edition>/', 'home', view_func=views.home)
app.add_url_rule('/variant/<variant>/', 'home', view_func=views.home)
app.add_url_rule('/variant/<variant>/<edition>/', 'home', view_func=views.home)

# popular
app.add_url_rule('/popular/', 'popular', view_func=views.popular)
app.add_url_rule('/popular/<theme>/', 'popular', view_func=views.popular)
app.add_url_rule('/popular/<theme>/<edition>/', 'popular', view_func=views.popular)
app.add_url_rule('/popular/<theme>/<edition>/<referrer>/', 'popular', view_func=views.popular)

# editor
app.add_url_rule('/edit/', 'edit', view_func=views.edit, methods=['GET', 'POST'])

app.add_url_rule('/message/', 'message', view_func=views.msg)

@app.errorhandler(404)
def page_not_found(e):
示例#33
0
from application import app
from handlers.home_handler import *
from handlers.account_handler import *
from handlers.posts_handler import *
from handlers.chat_handler import *

# Home
app.add_url_rule('/', 'home', view_func=home, methods=['GET'])

# Login
app.add_url_rule('/login', 'login', view_func=login_page, methods=['GET'])

# Board
app.add_url_rule('/posts', 'posts', view_func=posts, methods=['GET'])
app.add_url_rule('/posts', 'posts_add', view_func=post_add, methods=['POST'])
app.add_url_rule('/posts/<post_id>',
                 'posts_delete',
                 view_func=post_delete,
                 methods=['DELETE'])

# Chat
app.add_url_rule('/chat', 'chat', view_func=chat, methods=['GET'])
app.add_url_rule('/chat/setup',
                 'chat_setup',
                 view_func=chat_setup,
                 methods=['POST'])
app.add_url_rule('/chat/send_msg',
                 'chat_send_msg',
                 view_func=chat_send_message,
                 methods=['POST'])
示例#34
0
文件: views.py 项目: nwinter/bantling
        return jsonify(saved_names.to_dict())

    @login_required
    def post(self):
        liked = request.form.getlist("liked[]")
        hated = request.form.getlist("hated[]")
        user = users.get_current_user()
        key = user.user_id()
        saved_names = SavedNames.get_or_insert(key, user=key)
        saved_names.liked = liked
        saved_names.hated = hated
        saved_names.put()
        return jsonify(saved_names.to_dict())


app.add_url_rule("/saved_names/", view_func=SavedNamesView.as_view("saved_names"))


def list_names():
    """List all liked names for all users."""
    all_saved_names = SavedNames.query().fetch(100)
    me = users.get_current_user()
    if me:
        me = me.user_id()
        my_saved_names = filter(lambda x: x.user == me, all_saved_names)
    else:
        my_saved_names = []
    if len(my_saved_names):
        my_saved_names = my_saved_names[0]
    else:
        my_saved_names = {"liked": [], "hated": []}
示例#35
0
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views

## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# Say hello
app.add_url_rule('/hello/<username>', 'say_hello', view_func=views.say_hello)

# Examples list page
app.add_url_rule('/examples',
                 'list_examples',
                 view_func=views.list_examples,
                 methods=['GET', 'POST'])

# Examples list page (cached)
app.add_url_rule('/examples/cached',
                 'cached_examples',
示例#36
0
文件: urls.py 项目: adamreis/top-hn
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views

## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home, methods=['GET'])

# Download all the shit
app.add_url_rule('/scrape/', 'scrape', view_func=views.scrape, methods=['GET'])


## Error handlers
# Handle 404 errors
@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404


# Handle 500 errors
示例#37
0
URL dispatch route mappings and error handlers

"""

from flask import render_template

from application import app
from application.controllers import category, image
from application.models import ROOT_CAT_ID


## URL dispatch rules

# Home page
app.add_url_rule('/', 'home', view_func=category.home)

app.add_url_rule('/admin/', 'admin', view_func=category.admin)
app.add_url_rule('/admin/categories/', 'admin_categories', view_func=category.admin_categories, methods=['GET', 'POST'])
app.add_url_rule('/admin/categories/' + str(ROOT_CAT_ID) + '', 'admin_categories', view_func=category.admin_categories, methods=['GET', 'POST'])
app.add_url_rule('/admin/categories/<int:parent_id>', 'admin_category', view_func=category.admin_categories, methods=['GET', 'POST'])
app.add_url_rule('/admin/categories/move/<int:category_id>/<int:parent_id>', 'move_category', view_func=category.move_category, methods=['GET'])
app.add_url_rule('/admin/categories/move/<int:category_id>/' + str(ROOT_CAT_ID), 'move_category', view_func=category.move_category, methods=['GET'])
app.add_url_rule('/admin/category_delete/<int:category_id>', 'delete_category', view_func=category.delete_category, methods=['GET', 'POST'])
app.add_url_rule('/category/<int:parent_id>', 'category', view_func=category.category, methods=['GET'])

app.add_url_rule('/admin/images/', 'admin_images', view_func=image.admin_images, methods=['GET', 'POST'])
app.add_url_rule('/admin/images/' + str(ROOT_CAT_ID) + '', 'admin_images', view_func=image.admin_images, methods=['GET', 'POST'])
app.add_url_rule('/admin/images/<int:parent_id>', 'admin_images_in_category', view_func=image.admin_images, methods=['GET', 'POST'])
app.add_url_rule('/images', 'images', view_func=image.admin_images, methods=['GET'])
app.add_url_rule('/admin/image_delete/<int:image_id>', 'delete_image', view_func=image.delete_image, methods=['GET', 'POST'])
示例#38
0
urls.py

URL dispatch route mappings and error handlers

"""

from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule("/_ah/warmup", "warmup", view_func=views.warmup)

# Home page
app.add_url_rule("/?page=<page>", "main", view_func=views.main)
app.add_url_rule("/", "main", view_func=views.main)

# Contrived admin-only view example
app.add_url_rule("/admin_only", "admin_only", view_func=views.admin_only)

# Add new lie
app.add_url_rule("/new", "new_lie", view_func=views.new_lie, methods=["GET", "POST"])

## Error handlers
# Handle 404 errors
@app.errorhandler(404)
def page_not_found(e):
示例#39
0

class FriendsView(MethodView):
    def get(self):
        profile_id = request.args.get('profile_id')
        if not profile_id and not session.get('profile_id'):
            return Response('No profile specified. Please specify profile_id',
                            status=400)

        profile_id = profile_id or session.get('profile_id')
        user = User.get_by_id(profile_id)
        if not user:
            return Response(
                'No profile \'{}\' found. Please specify profile_id'.format(
                    profile_id),
                status=400)

        data = {
            'friends': [{
                'name': f.name
            } for f in ndb.get_multi(user.friends)]
        }
        data['count'] = len(data['friends'])

        return Response(json.dumps(data), status=200)


app.add_url_rule('/webhooks/friends',
                 view_func=FriendsWebhook.as_view('friends-webhook'))
app.add_url_rule('/api/friends', view_func=FriendsView.as_view('friends-view'))
示例#40
0
文件: urls.py 项目: iki/hack-bi-flow
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home, methods=['GET'])

# Status page
app.add_url_rule('/status', 'status', view_func=views.status, methods=['GET'])

# API
app.add_url_rule('/api/sync', view_func=views.sync, methods=['POST'])
app.add_url_rule('/api/sync/stop', view_func=views.sync_stop, methods=['POST'])
app.add_url_rule('/api/sync/status', view_func=views.sync_status, methods=['GET'])

## Error handlers
# Handle 404 errors
@app.errorhandler(404)
示例#41
0
"""
urls.py

URL dispatch route mappings and error handlers

"""

from flask import render_template

from application import app
from application import views

## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# Front page
app.add_url_rule('/front', 'front', view_func=views.front)

# Newest
app.add_url_rule('/newest', 'newest', view_func=views.newest)


## Error handlers
# Handle 404 errors
@app.errorhandler(404)
def page_not_found(e):
示例#42
0
        return self.page.meta.get('template', 'flatpage.html')

    def render_template(self, context):
        return render_template(self.get_template(), **context)

    def dispatch_request(self):
        app.page['title'] = ''
        app.page['description'] = ''
        response = {
            'app': app
        }
        context = { 'response': response, 'page': self.page }
        return self.render_template(context)

#app.add_url_rule('/about/updates/', view_func=FlatPageView.as_view('update', page_name='update'))
app.add_url_rule('/about/', view_func=FlatPageView.as_view('about', page_name='about'))
#app.add_url_rule('/about/notifications/', view_func=FlatPageView.as_view('notifications', page_name='notifications'))
#app.add_url_rule('/about/notifications/unsubscribe/', view_func=FlatPageView.as_view('unsubscribe', page_name='unsubscribe'))
#app.add_url_rule('', view_func=FlatPageView.as_view('', page_name=''))

"""
@app.route('/feeds/recent.atom')
def recent_feed():
    feed = AtomFeed('Colorado Bill Tracker: Recent',
                    feed_url=request.url, url=request.url_root)
    feed.add('Crime Data updated', '',
             content_type='html',
             url='http://denvercrimes.com/',
             updated=datetime.today(),
             published=datetime.today())
    return feed.get_response()
示例#43
0
from flask import render_template

from application import app
from application import views


app.add_url_rule('/', view_func=views.home, methods=['GET',]) # Main page
app.add_url_rule('/drug/orders/', view_func=views.add_order, methods=['POST',])
app.add_url_rule('/drug/orders/', view_func=views.get_order, methods=['GET',])
app.add_url_rule('/drug/orders/', view_func=views.delete_order, methods=['DELETE',])

## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

## Error handlers
# Handle 404 errors
@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404

# Handle 500 errors
@app.errorhandler(500)
def server_error(e):
    return render_template('500.html'), 500

示例#44
0
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See https://cloud.google.com/appengine/docs/python/config/appconfig
app.add_url_rule("/_ah/warmup", "warmup", view_func=views.warmup)

# Home page
app.add_url_rule("/", "home", view_func=views.home)

# About page
app.add_url_rule("/about/", "about", view_func=views.about)

# Random user page
app.add_url_rule("/random", "random_user", view_func=views.random_user)
app.add_url_rule("/random-user", "random_user", view_func=views.random_user)

# User page
app.add_url_rule("/u/<username>", "user_profile", view_func=views.user_profile)

# User existence check page
示例#45
0
urls.py

URL dispatch route mappings and error handlers

"""

from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# Say hello
# app.add_url_rule('/hello/<username>', 'say_hello', view_func=views.say_hello)

# Examples list page
# app.add_url_rule('/examples', 'list_examples', view_func=views.list_examples, methods=['GET', 'POST'])

# Contrived admin-only view example
# app.add_url_rule('/admin_only', 'admin_only', view_func=views.admin_only)

# Delete an example (post method only)
# app.add_url_rule('/examples/delete/<int:example_id>', view_func=views.delete_example, methods=['POST'])
示例#46
0
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)


## Main content

app.add_url_rule('/', 'index', view_func=views.index)
app.add_url_rule('/settings', 'change_user_settings', view_func=views.change_user_settings)

### Student-focused pages
app.add_url_rule('/complete-registration', 'complete_registration', view_func=views.complete_registration)
app.add_url_rule('/student/<student_id>', 'list_individual_student', view_func=views.list_individual_student)

### Admin-focused pages
app.add_url_rule('/students', 'list_all_students', view_func=views.list_all_students, methods=['GET', 'POST'])
app.add_url_rule('/admins', 'list_all_admins', view_func=views.list_all_admins, methods=['GET', 'POST'])
app.add_url_rule('/sessions', 'list_all_sessions', view_func=views.list_all_sessions, methods=['GET', 'POST'])
示例#47
0
from application import db, app
from application.models import *
from application.forms import *
from application.functions import *

from sqlalchemy import create_engine

import json, os

engine = create_engine(app.config.get('SQLALCHEMY_DATABASE_URI'))

if not os.path.exists('./database.db'):
    Base.metadata.create_all(engine)

app.add_url_rule('/', view_func=list_cat_items)
app.add_url_rule('/cats', view_func=add_a_cat, methods=['GET', 'POST'])
app.add_url_rule('/items', view_func=add_an_item, methods=['GET', 'POST'])
app.add_url_rule('/catalog/<path:cat_name>/items', view_func=cat_items)
app.add_url_rule('/catalog/<path:cat_name>/<path:item_name>', view_func=show_item)
app.add_url_rule('/catalog/<path:cat_name>/<path:item_name>/delete', view_func=del_item, methods=['GET', 'POST'])
app.add_url_rule('/catalog/<path:cat_name>/<path:item_name>/edit', view_func=edit_item, methods=['GET', 'POST'])

app.add_url_rule('/catalog.json', view_func=catalog_api)

app.add_url_rule('/login', view_func=login)
app.add_url_rule('/gconnect', view_func=gconnect, methods=['POST'])
app.add_url_rule('/logout', view_func=logout)
app.add_url_rule('/gdisconnect', view_func=gdisconnect)
app.add_url_rule('/signup', view_func=signup)
示例#48
0
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views

## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# Say hello
app.add_url_rule('/hello/<username>', 'say_hello', view_func=views.say_hello)

# Examples list page
app.add_url_rule('/tests',
                 'list_tests',
                 view_func=views.list_tests,
                 methods=['GET', 'POST'])

# Register
app.add_url_rule('/register',
                 'register',
示例#49
0
文件: urls.py 项目: pawl/GuessMyQuiz
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule("/_ah/warmup", "warmup", view_func=views.warmup)

# Home page
app.add_url_rule("/", "home", view_func=views.home)

# main
app.add_url_rule("/guess", "guess", view_func=views.guess, methods=["GET", "POST"])

## Error handlers
# Handle 404 errors
@app.errorhandler(404)
def page_not_found(e):
    return render_template("404.html"), 404


# Handle 500 errors
示例#50
0
urls.py

URL dispatch route mappings and error handlers

"""

from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# Blog
app.add_url_rule('/blog', 'blog', view_func=views.blog)

# Contact page
app.add_url_rule('/contact', 'contact', view_func=views.contact)

# Admin
app.add_url_rule('/admin_only', 'admin_only', view_func=views.admin_only)

# Blog new posts page
app.add_url_rule('/blog/new', 'new_post', view_func=views.new_post, methods=['GET', 'POST'])
示例#51
0
#
# urls.py
#

from flask import render_template

from application import app, handlers

# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=handlers.warmup)

# Home page
app.add_url_rule('/', view_func=handlers.home)

# Ajaxy page
app.add_url_rule('/ajaxy', view_func=handlers.AjaxyView.as_view('ajaxy'))

####################################################################################################
# Error handlers


# Handle 403 errors
@app.errorhandler(403)
def forbidden(e):
    return render_template('errors/403.html'), 403


# Handle 404 errors
@app.errorhandler(404)
def page_not_found(e):
示例#52
0
文件: urls.py 项目: pawl/pdfreverse
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.upload_file)

## Error handlers
# Handle 404 errors
@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404

# Handle 500 errors
@app.errorhandler(500)
def server_error(e):
    return render_template('500.html'), 500
示例#53
0
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/', 'home', view_func=views.home)

# main
app.add_url_rule('/match', 'match', view_func=views.match, methods=['GET', 'POST'])

## Error handlers
# Handle 404 errors
@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404

# Handle 500 errors
@app.errorhandler(500)
示例#54
0
from application import app
from handlers.home_handler import *
from handlers.account_handler import *
from handlers.posts_handler import *
from handlers.chat_handler import *


# Home
app.add_url_rule('/', 'home', view_func=home, methods=['GET'])

# Login
app.add_url_rule('/login', 'login', view_func=login_page, methods=['GET'])

# Board
app.add_url_rule('/posts', 'posts', view_func=posts, methods=['GET'])
app.add_url_rule('/posts', 'posts_add', view_func=post_add, methods=['POST'])
app.add_url_rule('/posts/<post_id>', 'posts_delete', view_func=post_delete, methods=['DELETE'])

# Chat
app.add_url_rule('/chat', 'chat', view_func=chat, methods=['GET'])
app.add_url_rule('/chat/setup', 'chat_setup', view_func=chat_setup, methods=['POST'])
app.add_url_rule('/chat/send_msg', 'chat_send_msg', view_func=chat_send_message, methods=['POST'])
示例#55
0
urls.py

URL dispatch route mappings and error handlers

"""

from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Examples list page
app.add_url_rule('/api/', 'read', view_func=views.read, methods=['GET'])
app.add_url_rule('/api/', 'create', view_func=views.create, methods=['POST'])
app.add_url_rule('/api/<int:id>', 'update', view_func=views.update, methods=['PUT'])
app.add_url_rule('/api/<int:id>', 'delete', view_func=views.delete, methods=['DELETE'])

app.add_url_rule('/api/authorize', 'authorize', view_func=views.authorize, methods=['GET'])
app.add_url_rule('/api/authorize', 'authorization_request', view_func=views.authorization_request, methods=['POST'])
# Contrived admin-only view example
app.add_url_rule('/admin_only', 'admin_only', view_func=views.admin_only)

app.add_url_rule('/api/tickets', 'read_tickets', view_func=views.read_tickets, methods=['GET'])
app.add_url_rule('/api/tickets/<int:id>', 'update_tickets', view_func=views.update_tickets, methods=['PUT'])
示例#56
0
文件: urls.py 项目: wcweb/avaUI
urls.py

URL dispatch route mappings and error handlers

"""

from flask import render_template,url_for

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
# app.add_url_rule('/', 'home', view_func=views.home)

# Say hello
app.add_url_rule('/hello/<username>', 'say_hello', view_func=views.say_hello)

# Examples list page
app.add_url_rule('/examples', 'list_examples', view_func=views.list_examples, methods=['GET', 'POST'])

# Contrived admin-only view example
app.add_url_rule('/admin_only', 'admin_only', view_func=views.admin_only)

# Delete an example (post method only)
app.add_url_rule('/examples/delete/<int:example_id>', view_func=views.delete_example, methods=['POST'])
示例#57
0
"""
urls.py

URL dispatch route mappings and error handlers

"""
from flask import render_template

from application import app
from application import views


## URL dispatch rules
# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=views.warmup)

# Home page
app.add_url_rule('/',                 'home', view_func=views.index, methods=['GET', 'POST'])
app.add_url_rule('/index',            'home', view_func=views.index, methods=['GET', 'POST'])
app.add_url_rule('/index/<int:page>', 'home', view_func=views.index, methods=['GET', 'POST'])

# Login
app.add_url_rule('/login', 'login', view_func=views.login, methods=['GET', 'POST'])

# Logout
app.add_url_rule('/logout', 'logout', view_func=views.logout, methods=['GET', 'POST'])

# User
app.add_url_rule('/user/<nickname>', 'view user', view_func=views.user)
示例#58
0
文件: urls.py 项目: ozan/fitbit-api
"""
URL dispatch route mappings and error handlers

"""

from flask import render_template

from application import app
from application import views


## URL dispatch rules

# Historic data API endpoints
app.add_url_rule('/weight', 'weight', view_func=views.weight)
app.add_url_rule('/sleep', 'sleep', view_func=views.sleep)
app.add_url_rule('/sleep/awoken', 'awoken', view_func=views.awoken)
app.add_url_rule('/mood', 'mood', view_func=views.mood)

# App Engine warm up handler
# See http://code.google.com/appengine/docs/python/config/appconfig.html#Warming_Requests
app.add_url_rule('/_ah/warmup', 'warmup', view_func=lambda: '')


## Error handlers
# Handle 404 errors
@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404

# Handle 500 errors
示例#59
0
文件: urls.py 项目: jongha/thunderfs
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from flask import render_template

from application import app, get_context
from application.views import index
from application.views import file

from flask.ext.babel import Babel, gettext, ngettext, lazy_gettext
from flask import Flask, request, session, g, redirect, url_for, abort, \
     render_template, flash
     
## URL dispatch rules
app.add_url_rule('/', view_func=index.main)
app.add_url_rule('/put', view_func=file.put, methods=['POST', 'GET'])
app.add_url_rule('/<id>', view_func=file.get, methods=['GET'])

## Error handlers
# Handle 404 errors
@app.errorhandler(404)
def page_not_found(e):
    return render_template('errors/404.html', context=get_context()), 404

# Handle 500 errors
@app.errorhandler(500)
def server_error(e):
    return render_template('errors/500.html', context=get_context()), 500