Commit 0c5ac2ae28811af00700158cff13a0ce9732954a

Authored by Antoine Goutenoir
1 parent 8c465c94
Exists in master

Actually use the counter and tweak train gcd correction.

flaskr/__init__.py
... ... @@ -23,6 +23,7 @@ from flaskr.extensions import (
23 23 )
24 24  
25 25 from flaskr.content import content
  26 +from flaskr.core import increment_hit_counter, get_hit_counter
26 27  
27 28 from markdown import markdown
28 29  
... ... @@ -78,6 +79,7 @@ def create_app(object_name):
78 79 return dict(
79 80 content=content,
80 81 version=version,
  82 + visits=get_hit_counter(),
81 83 )
82 84  
83 85 # Markdown jinja2 filter
... ... @@ -88,9 +90,6 @@ def create_app(object_name):
88 90 # Authentication Gate for the Admin
89 91 @app.before_first_request
90 92 def restrict_admin_url():
91   -
92   - # print('VF', app.view_functions)
93   -
94 93 endpoint = 'admin.index'
95 94 url = url_for(endpoint)
96 95 admin_index = app.view_functions.pop(endpoint)
... ...
flaskr/laws/travel_emission_linear_fit.py
... ... @@ -77,7 +77,9 @@ class EmissionModel(BaseEmissionModel):
77 77 }
78 78  
79 79 def compute_train_footprint(self, distance):
80   - return distance * 0.023
  80 + gcd_to_road_correction = 1.30 # See issue #32
  81 + train_emission = 0.023 # kg/km
  82 + return gcd_to_road_correction * distance * train_emission
81 83  
82 84 def compute_airplane_footprint(
83 85 self,
... ...
flaskr/templates/base.html
... ... @@ -85,6 +85,8 @@
85 85 </div>
86 86 <div class="col-lg-4 text-center">
87 87 {{ content.footer.credits }}
  88 + <br>
  89 + {{ visits }} visits since 2020
88 90 </div>
89 91 <div class="col-lg-4 text-center">
90 92 <a href="http://www.irap.omp.eu" class=""><img src="/static/img/irap.png" alt="IRAP" width="110px"></a>
... ...