Created
May 4, 2018 14:58
-
-
Save dunossauro/c369990d96d364fb2970dfa14bd13bd5 to your computer and use it in GitHub Desktop.
Bottle merge route example
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
from bottle import Bottle | |
app = Bottle() | |
@app.get('/api/v1/test_route1') | |
def get_route1(): | |
return '42' |
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
from bottle import Bottle | |
app = Bottle() | |
@app.get('/api/v1/test_route2') | |
def get_route2(): | |
return '42' |
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
from bottle import Bottle, run | |
from routes import routes | |
app = Bottle() | |
app.merge(routes) | |
run(app) |
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
from bottle import Bottle | |
from app_1 import app as app_1 | |
from app_2 import app as app_2 | |
routes = Bottle() | |
routes.merge(app_1) | |
routes.merge(app_2) |
i know this is old... but im stuck..
so if manage.py sets up the various stuff like config etc for the application then how do you reference those items that are setup in "manage.py" inside each app? or are wee supposed to set up config / app variables on each app every time?
manage.py
from bottle import Bottle, run
from routes import routes
app = Bottle()
app.my_value = "hello" # <---- must be accessible to all "apps"
app.merge(routes)
run(app)
app_1.py
from bottle import Bottle
app = Bottle()
@app.get('/api/v1/test_route1')
def get_route1():
return app.my_value # <------- how would i get the value in here?
just short of setting up a "Base" class for it im not having much joy :(
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/rochacbruno/e44c1f0f43e89093bf7ddba77ee9feef