-
-
Save mrjoes/b42defe0f420097f40c7 to your computer and use it in GitHub Desktop.
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 flask import Flask | |
from flask.ext import admin | |
# Views | |
class FirstView(admin.BaseView): | |
@admin.expose('/') | |
def index(self): | |
return self.render('first.html') | |
class SecondView(admin.BaseView): | |
@admin.expose('/') | |
def index(self): | |
return self.render('second.html') | |
# Create flask app | |
app = Flask(__name__, template_folder='templates') | |
# Flask views | |
@app.route('/') | |
def index(): | |
return '<a href="/admin1">Click me to get to Admin 1</a><br/><a href="/admin2">Click me to get to Admin 2</a>' | |
if __name__ == '__main__': | |
# Create first administrative interface under /admin1 | |
admin1 = admin.Admin(app, url='/admin1') | |
admin1.add_view(FirstView()) | |
# Create second administrative interface under /admin2 | |
admin2 = admin.Admin(app, url='/admin2', endpoint='admin2') | |
admin2.add_view(SecondView()) | |
admin2.add_view(FirstView(endpoint='a1')) | |
admin2.add_view(FirstView(endpoint='a2')) | |
admin2.add_view(FirstView(endpoint='a3')) | |
# Start app | |
app.debug = True | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment