A simple example web application with Python web.py and the Bootstrap 3 framework.
- XMLHttpRequest
- Worker-Thread with message-queue
- simple chat function
- flot-live-chart
This is the "index"-page of the SimpleWebPy-Site. It contains a very simple made chat:
Here you can see a chart made with flot. It shows the cpu ussage of the server cpu in percent.
- web.py
- psutil
If you need pip
type python get-pip.py
in your command promt.
python -m pip install web.py
python -m pip install psutil
Put in your command promt (cmd): netsh winhttp show proxy
Copy the given proxyHost and port and paste it into the command: SET HTTPS_PROXY=<proxyHost>:<proxyPort>
Now you should be able to use pip
as written above.
If you need pip
type python get-pip.py
in your terminal.
pip install web.py
pip install psutil
Latest Release:
Extract it to the directory you want to start the website from. For example: \home\john\web\
Now start your simpleSite with the command:
Windows
python \home\john\web\SimpleWebPy\simpleSite\processor\SimpleSiteApp.py
Linux
python /home/john/web/SimpleWebPy/simpleSite/processor/SimpleSiteApp.py
Windows and Linux
Press ctrl + c
in your commandline or terminal to stop the web application.
Note: You have to close all sessions (open internet browser) to close the script with ctrl + c
. Otherwise, the web.py application and the "input"-thread prohibits the close process.
You can also kill the python process, but I do not recommend this way.
/simpleSite
│
├───/html_public
│ │
│ └───/pages # Save your HTML-files in this folder
│ │
│ ├───base.html # One of the HTML-file
│ ├───index.html # One of the HTML-file
│ ├───serverussage.html # One of the HTML-file
│ └───/Bootstrap Templates # Original Bootstrap-files
│
├───/lib_systemd_system
│ │
│ └───simplesite.service # Service-file for systemd controlled autostart
│
└───/processor
│
├───/sessions # Generated by wep.py to save session-data
│
├───/static # folder for static files like .js .css .less etc.
│ │
│ ├───/data # folder for your js-Files to print charts
│ │ │
│ │ ├───chart.js # javascript to handle a simple chat
│ │ └───cpu-live-data.js # javascript to print the cpu ussage in a chart
│ │
│ └───... # Other files used by the bootstrap framework
│
└───simpleSiteApp.py # python-script of your web application
The following diagram shows you, how the AJAX request in the chat works.
The same principle is used in the page serverussage.
- Bootstrap-Homepage - http://getbootstrap.com/
- Python-Module web.py - http://webpy.org/
- Python-Module psutil - https://pypi.python.org/pypi/psutil
- Flot: JavaScript plotting library for jQuery - http://www.flotcharts.org/