Python Bootstrap

Go down

Python Bootstrap Empty Python Bootstrap

Post by jamied_uk on 17th November 2016, 12:56

Using Bootstrap
Bootstrap is a collection of CSS styles and simple javascript actions that are easily applied to any web page.

The slides you're looking at, as well as the other pages in the course website, are styled using Bootstrap at its most basic application.

Bootstrap styles can be saved locally or accessed dynamically with a network connection. Because I sometimes work offline, I saved them in order to access them locally.

To use local Bootstrap files, download from the class data page, and unzip in the same directory as your HTML page (the until will create a static folder containing other folders).

In your HTML page, place the following code in your tag (bolded additions are not necessary):

 <title>My Webpage, by Y.T.</title>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="stylesheet" href="static/css/Bootstrap/bootstrap.min.css">
 pre {
 height: auto;
 max-height: 500px;
 overflow: auto;
 <script src="static/css/Bootstrap/js/bootstrap.min.js"></script>
 function open_window(url) {;

The bolded portions are additions that I made -- as you can see, it's possible to customize Bootstrap by adding one or more CSS Styles to the same container tag.

To use Bootstrap through a network connection, the tags referencing .css and .js files should look like this:

[size=20]<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>


Many themes have been added to and are available through Bootstrap.

The Bootstrap docs provide a clear rundown of what is available both for CSS and Javascript actions.

Posts : 2471
Join date : 2010-05-09
Age : 36
Location : UK

Back to top Go down

Python Bootstrap Empty Re: Python Bootstrap

Post by jamied_uk on 17th November 2016, 13:03

Using Flask

Flask: a "lightweight" framework for serving web applications.
Flask uses a simple dispatch mechanism for launching functions based on the URL

from flask import Flask
app = Flask(__name__)      # a Flask object

@app.route('/')            # called when visiting web URL
def hello_world():
    return 'Hello World!<BR><BR>Say <A HREF="/bye">Bye!</A>'

@app.route('/bye')         # called when visiting web URL
def goodbye():
    return 'Get thee to a nunnery!<BR><BR>Say <A HREF="/">Hi!</A>'

if __name__ == '__main__':, port=5000) # app starts serving in debug mode on port 5000

The functions preceded by @app.route() decorators may be called event functions; these are called in response to an event, namely the calling of a URL by the user.

In the simplest application, returning a string from an event function causes Flask to return this string to the browser. (In most cases, the browser will interpret a string as HTML.)

Note the tags that call this app with one or the other page's URL: this app allows you to click a link that flips back and forth between pages.

Flask is among the simplest libraries for writing and serving web applications, and is perfectly suited to a wide range of domains. By contrast, Django is often used for larger-scale websites, although its configuration requirements are more demanding and its learning curve is steeper.

Back to top Go down

Back to top

Permissions in this forum:
You cannot reply to topics in this forum