Difference between revisions of "PyFlaskBootstrap4"
Jump to navigation
Jump to search
(→Links) |
|||
| Line 83: | Line 83: | ||
helloWeb.run(args) | helloWeb.run(args) | ||
</source> | </source> | ||
| + | = Server Sent Events = | ||
| + | == Progressbar Example == | ||
| + | === Server Side Flask Code === | ||
| + | <source lang='python'> | ||
| + | def progressFeed(self): | ||
| + | ''' | ||
| + | feed progress info as json | ||
| + | ''' | ||
| + | self.pc=0 | ||
| + | def progress(): | ||
| + | time.sleep(0.5) | ||
| + | self.pc=(self.pc+5) % 100 | ||
| + | pcdict={"progress":self.pc} | ||
| + | return json.dumps(pcdict) | ||
| + | |||
| + | sse=self.sseBluePrint | ||
| + | return sse.streamFunc(progress) | ||
| + | </source> | ||
| + | |||
= Links = | = Links = | ||
* https://icons.getbootstrap.com/ | * https://icons.getbootstrap.com/ | ||
* http://helloflask.com/en/ | * http://helloflask.com/en/ | ||
* https://wtforms.readthedocs.io/en/2.3.x/ | * https://wtforms.readthedocs.io/en/2.3.x/ | ||
Revision as of 19:36, 12 February 2021
| OsProject | |
|---|---|
| id | PyFlaskBootstrap4 |
| state | |
| owner | WolfgangFahl |
| title | Flask + Bootstrap 4 static components and templates for webprojects |
| url | https://github.com/WolfgangFahl/pyFlaskBootstrap4 |
| version | 0.0.4 |
| description | |
| date | 2021/01/09 |
| since | |
| until | |
What is it?
A python library to get
- https://www.python.org/
- https://palletsprojects.com/p/flask/
- https://getbootstrap.com/
- https://www.sqlalchemy.org/
as a combined solution with some extra functionality. This project builds on
and adds support for
- SQLAlchemy-Utils custom data types and utility functions
- WTForms data validation, CSRF protection, I18N and more
- pydevd remote debugging support
- Using flask inside class
- Widgets
- login blueprint
- datatables
- Server Sent Event Support
Demos
see
Installation
pip install pyFlaskBootstrap4
Tutorial
HelloWeb application
see helloweb.py
'''
Created on 2021-01-08
This is a demo application for https://github.com/WolfgangFahl/pyFlaskBootstrap4
@author: wf
'''
from fb4.app import AppWrap
from flask import render_template
class HelloWeb(AppWrap):
'''
a sample web application
'''
def __init__(self):
'''
Constructor
'''
super().__init__()
def home(self):
'''
render the home page of the HelloWeb application
'''
html = render_template("bootstrap.html", title="HelloWeb demo application",content="Welcome to the Flask + Bootstrap4 Demo web application",error=None)
return html
helloWeb=HelloWeb()
app=helloWeb.app
@app.route('/')
def home():
return helloWeb.home()
if __name__ == '__main__':
parser=helloWeb.getParser("Flask + Bootstrap4 Demo Web Application")
args=parser.parse_args()
helloWeb.optionalDebug(args)
helloWeb.run(args)
Server Sent Events
Progressbar Example
Server Side Flask Code
def progressFeed(self):
'''
feed progress info as json
'''
self.pc=0
def progress():
time.sleep(0.5)
self.pc=(self.pc+5) % 100
pcdict={"progress":self.pc}
return json.dumps(pcdict)
sse=self.sseBluePrint
return sse.streamFunc(progress)