Commit 4259c8f8 authored by Petrus J.v.Rensburg's avatar Petrus J.v.Rensburg

Make 'auth' example deployable.

parent 7e8266a0
...@@ -14,7 +14,7 @@ app = Flask(__name__) ...@@ -14,7 +14,7 @@ app = Flask(__name__)
app.config['SECRET_KEY'] = '123456790' app.config['SECRET_KEY'] = '123456790'
# Create in-memory database # Create in-memory database
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.sqlite' app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///sample.sqlite'
app.config['SQLALCHEMY_ECHO'] = True app.config['SQLALCHEMY_ECHO'] = True
db = SQLAlchemy(app) db = SQLAlchemy(app)
...@@ -135,15 +135,16 @@ def logout_view(): ...@@ -135,15 +135,16 @@ def logout_view():
login.logout_user() login.logout_user()
return redirect(url_for('index')) return redirect(url_for('index'))
if __name__ == '__main__': # Initialize flask-login
# Initialize flask-login init_login()
init_login()
# Create admin # Create admin
admin = admin.Admin(app, 'Auth', index_view=MyAdminIndexView()) admin = admin.Admin(app, 'Auth', index_view=MyAdminIndexView())
# Add view # Add view
admin.add_view(MyModelView(User, db.session)) admin.add_view(MyModelView(User, db.session))
if __name__ == '__main__':
# Create DB # Create DB
db.create_all() db.create_all()
......
...@@ -4,13 +4,10 @@ ...@@ -4,13 +4,10 @@
<div class="row-fluid"> <div class="row-fluid">
<h1>Flask-Admin example</h1> <h1>Flask-Admin example</h1>
<p class="lead"> <p class="lead">
Custom forms Authentication
</p> </p>
<p> <p>
This example shows how you can define your own custom forms by using form rendering rules. This example shows how you can use Flask-Login for authentication. It is only intended as a basic demonstration, so please don't freak out when you see passwords being stored as plain text.
</p>
<p>
It also demonstrates general file handling as well as the handling of image files specifically.
</p> </p>
<a class="btn btn-primary" href="/"><i class="icon-arrow-left icon-white"></i> Back</a> <a class="btn btn-primary" href="/"><i class="icon-arrow-left icon-white"></i> Back</a>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment