-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
49 lines (38 loc) · 1013 Bytes
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
This module is an example of
how to use the Flask-Sustainable package.
It is a simple Flask application that uses the Flask-Sustainable package.
"""
import flask
from flask_sustainable import Sustainable
from flask_sustainable.indicator import (
PerfCPU,
PerfEnergy,
PerfPower,
PerfRAM,
PerfTime,
)
from flask_sustainable.score import PerfScoreCO2
def create_app() -> flask.Flask:
"""Create and configure an instance of the Flask application.
This is a simple Flask application that uses the Flask-Sustainable package.
:return: Flask application instance
"""
app = flask.Flask(__name__)
sustainable = Sustainable(app)
sustainable.add_indicators(
PerfTime(),
PerfCPU(),
PerfRAM(),
PerfEnergy(),
PerfPower(),
)
sustainable.add_scores(
PerfScoreCO2(),
)
@app.route("/")
def _():
return "Hello, World!"
return app
if __name__ == "__main__":
create_app().run(debug=True)