Created
June 4, 2014 19:28
-
-
Save beeftornado/11e98eb1f4bc598ca90a to your computer and use it in GitHub Desktop.
API route prefixes with bottle. So you don't have to type @route('/api/name/blah') every time. You can just use @route('/blah')
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# # Site API | |
# ## Imports | |
# Standard libs | |
# Third party libs | |
import bottle | |
from bottle import get, post, route | |
# Project libs | |
import api_clients | |
# ## Setup | |
# Which API is this? Will be installed at /api/API_NAME | |
API_NAME = 'site' | |
# 'application' to install the routes on | |
api = bottle.Bottle() | |
# ## APIs | |
# GET /api/site/check | |
@api.get("/check") | |
def test(): | |
return 'Working'.encode('utf-8') | |
# Mount the routes to the app that gets started up | |
bottle.default_app().mount(prefix='/api/{0}'.format(API_NAME), app=api) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment