Commit a18c580d authored by erreur401's avatar erreur401

first test flask-security + absolute path in templates

parent cc1567c6
......@@ -58,5 +58,61 @@ def event():
#def not_found(error):
# return render_template('error.html'), 404
# /
# ______ _ _ _____ _ _
# | ___| | | | / ___| (_) |
# | |_ | | __ _ ___| | __ \ `--. ___ ___ _ _ _ __ _| |_ _ _
# | _| | |/ _` / __| |/ / `--. \/ _ \/ __| | | | '__| | __| | | |
# | | | | (_| \__ \ < /\__/ / __/ (__| |_| | | | | |_| |_| |
# \_| |_|\__,_|___/_|\_\ \____/ \___|\___|\__,_|_| |_|\__|\__, |
# ______ __/ |
# |______| |___/
# /
from flask_mongoengine import MongoEngine
from flask_security import Security, MongoEngineUserDatastore, UserMixin, RoleMixin, login_required
# Create app
app.config['SECRET_KEY'] = 'super-secret'
# MongoDB Config
app.config['MONGODB_DB'] = 'mydatabase'
app.config['MONGODB_HOST'] = 'localhost'
app.config['MONGODB_PORT'] = 27017
# Create database connection object
db = MongoEngine(app)
class Role(db.Document, RoleMixin):
name = db.StringField(max_length=80, unique=True)
description = db.StringField(max_length=255)
class User(db.Document, UserMixin):
email = db.StringField(max_length=255)
password = db.StringField(max_length=255)
active = db.BooleanField(default=True)
confirmed_at = db.DateTimeField()
roles = db.ListField(db.ReferenceField(Role), default=[])
# Setup Flask-Security
user_datastore = MongoEngineUserDatastore(db, User, Role)
security = Security(app, user_datastore)
# Create a user to test with
@app.before_first_request
def create_user():
user_datastore.create_user(email='erreur401@gmail.com', password='password')
# Views
@app.route('/dashboard')
@login_required
def dashboard():
return render_template('dashboard.html')
# APP RUN
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)
......@@ -24,8 +24,8 @@
{% include 'footer.html' %}
{% endblock footer %}
<script src="../static/node_modules/jquery/dist/jquery.min.js"></script>
<script src="../static/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="../static/js/main.js"></script>
<script src="{{ url_for('static', filename='node_modules/jquery/dist/jquery.min.js')}}"></script>
<script src="{{ url_for('static', filename='node_modules/bootstrap/dist/js/bootstrap.min.js')}}"></script>
<script src="{{ url_for('static', filename='js/main.js')}}"></script>
</body>
</html>
{% extends "base.html" %}
{% block content %}
LOGGED BEBE
{% endblock %}
<!-- LOAD BOOTSTRAP -->
<link href="../static/node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="{{ url_for('static', filename='node_modules/bootstrap/dist/css/bootstrap.min.css')}}" rel="stylesheet" media="screen">
<!-- LAOD MAIN CSS FILE -->
<link href="../static/css/style.css" rel="stylesheet" media="screen">
<link href="{{ url_for('static', filename='css/style.css')}}" rel="stylesheet" media="screen">
<!-- LOAD MD CONTENT SPECIFIC CSS -->
<link href="../static/css/mdcss.css" rel="stylesheet" media="screen">
<link href="{{ url_for('static', filename='css/mdcss.css')}}" rel="stylesheet" media="screen">
{{path}}
\ No newline at end of file
......@@ -2,19 +2,19 @@
{% block content %}
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="../static/img/jumbo.png" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="../static/img/jumbo.png" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="../static/img/jumbo.png" alt="Third slide">
</div>
</div>
</div>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="../static/img/jumbo.png" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="../static/img/jumbo.png" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="../static/img/jumbo.png" alt="Third slide">
</div>
</div>
</div>
<div class="homePush">
<div class="row no-gutter">
......
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