Skip to content

Instantly share code, notes, and snippets.

@beeftornado
Created June 4, 2014 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beeftornado/11e98eb1f4bc598ca90a to your computer and use it in GitHub Desktop.
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')
# -*- 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