Exemplo n.º 1
0
def register_api(view, endpoint, url, pk='id', pk_type='string'):
    view_func = view.as_view(endpoint)
    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', 'PUT', 'DELETE'])
Exemplo n.º 2
0
from app import UserAPI
from settings import app

user_view = UserAPI.as_view('user_api')
app.add_url_rule('/users/', defaults={'user_id':None},view_func=user_view, methods=['GET',])
Exemplo n.º 3
0
import os
from settings import app
from accounts.views import Users, Authentication

app.add_url_rule("/api/v1/accounts", view_func=Users.as_view("users"))
app.add_url_rule("/api/v1/accounts/<todo_id>", view_func=Users.as_view("todo"))
app.add_url_rule("/api/v1/auth", view_func=Authentication.as_view("auth"))

if __name__ == "__main__":
    app.run(debug=True)
Exemplo n.º 4
0
from settings import app
from views import index, add_query, skip

# set urls
app.add_url_rule('/', 'index', index, methods=["GET"])
app.add_url_rule('/add_query', 'add_query', add_query, methods=["POST"])
app.add_url_rule('/skip', 'skip', skip, methods=["GET"])


# run app
if __name__ == '__main__':
    # db.create_all()                              # create a new database at launch
    app.run(host='0.0.0.0', port=8080, debug=False)
Exemplo n.º 5
0
from views import MainHandler, JSHandler, CSSHandler, FeatureHandler, DropFeatureHandler
from settings import app

app.add_url_rule('/static/js/<path:path>', view_func=JSHandler.as_view('js'))
app.add_url_rule('/static/css/<path:path>',
                 view_func=CSSHandler.as_view('css'))
app.add_url_rule('/feature/create/', view_func=MainHandler.as_view('feature'))
app.add_url_rule('/features/', view_func=FeatureHandler.as_view('featurepage'))
app.add_url_rule('/feature/getall/',
                 view_func=FeatureHandler.as_view('getallfeatures'))
app.add_url_rule('/feature/dropall/',
                 view_func=DropFeatureHandler.as_view('dropallfeature'))
app.add_url_rule('/', view_func=MainHandler.as_view('main'))
Exemplo n.º 6
0
from settings import app
from views import index, register, login, logout, search, books, reviews, get_book_api

# index
app.add_url_rule("/", view_func=index)

# register
app.add_url_rule("/register", view_func=register, methods=['GET', 'POST'])

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

# logout
app.add_url_rule("/logout", view_func=logout)

# search
app.add_url_rule("/search", view_func=search, methods=['GET'])

# book page
app.add_url_rule("/books/<book_id>", view_func=books)

# reviews
app.add_url_rule("/reviews/<book_id>",
                 view_func=reviews,
                 methods=['GET', 'POST'])

# API
app.add_url_rule("/api/<isbn>", view_func=get_book_api)
Exemplo n.º 7
0
from settings import app
from views import (
	NewsletterSubscriptionCreateView,
	NewsletterSubscriptionConfirmationView,
	NewsletterSubscriptionDeleteView
)


app.add_url_rule(
	'/newsletter-subscription',
	view_func=NewsletterSubscriptionCreateView.as_view(
		'newsletter_subscription__create'
	)
)
app.add_url_rule(
	'/newsletter-subscription/<slug>/confirm',
	view_func=NewsletterSubscriptionConfirmationView.as_view(
		'newsletter_subscription__confirm'
	)
)
app.add_url_rule(
	'/newsletter-subscription/<slug>',
	view_func=NewsletterSubscriptionDeleteView.as_view(
		'newsletter_subscription__delete'
	)
)
Exemplo n.º 8
0
from settings import app
from views import user

app.add_url_rule('/', view_func=user.index)
app.add_url_rule('/users', view_func=user.UserApi.as_view('user'))
app.add_url_rule('/users/<int:user_id>',
                 view_func=user.UserItemApi.as_view('userItem'))