3

I'm having some problems to get a simple flask app to use the flask-bootstrap package.

Following the documentation I installed flask-bootstrap, created the 2 files below and this worked fine. The problem I'm facing is that when I access index.html in the browser I see only the text bootstrap/base.html returned and see no reference to the bootstrap css files when I view the source.

Appreciate any guidance on what I am missing here. Thanks.

__init__.py

from flask import Flask, render_template from flask.ext.bootstrap import Bootstrap app = Flask(__name__) bootstrap = Bootstrap(app) @app.route("/") def homepage(): return render_template('index.html') if __name__ == "__main__": app.run(debug=True) 

index.html

{% extends "bootstrap/base.html" %} {% block title %}This is an example page{% endblock %} {% block navbar %} <div class="navbar navbar-fixed-top"> <!-- ... --> </div> {% endblock %} {% block content %} <h1>Hello, Bootstrap</h1> {% endblock %} 
10
  • Are you running your flask APP ??? Plus to see the effect, you should run your app from a browser by typing for example localhost:5000, depending on that you configure your flask app Commented Mar 19, 2017 at 13:06
  • Thanks for response. I have the app on a server and access the domain via the browser. So should be running ok. Without the extends bootstrap the app runs ok. Commented Mar 19, 2017 at 13:17
  • I'm very confused here , you said "created the 2 files below and this worked fine" and then you said "when I access index.html", so how did it work for u in the first place and how are u accessing index.html?, shouldn't index.html be the root page just by typing in the browser localhost:5000 for example? Commented Mar 19, 2017 at 14:03
  • Sorry. I meant the installation of flask bootstrap was fine and the upload of the files to the server was successful. When i say access index.html i mean i goto www.mydomain.com/ Commented Mar 19, 2017 at 14:07
  • Are u using some sort of Virtual Env? Commented Mar 19, 2017 at 14:18

1 Answer 1

1

Thank you for the hints regarding the setup and proper use of virtualenv.

After some further digging I discovered that I should have the following 2 lines added to the top of flaskapp.wsgi since I installed bootstrap on the virtual environment created for my app, namely venv

activate_this = '/var/www/FlaskApp/FlaskApp/venv/bin/activate_this.py' execfile(activate_this, dict(__file__=activate_this)) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.