Skip to content

Commit

Permalink
better visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
Aimen-prog committed Jan 7, 2024
1 parent 494d2d7 commit 9f46f83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Big-Job/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ def emission_contributions():
def annual_emissions():
electricity_consumed = (request.form['countryInput'])
if electricity_consumed == "":
return render_template('co2.html', error="Please select a correct consumption value (in kW)")
return render_template('co2.html', error="Error in your selection: Please select a correct consumption value (in kW)")

electricity_consumed = float(electricity_consumed)
selected_country = request.form['countrySelect']

if selected_country == "all":
return render_template('co2.html', error= "Please select a single country")
return render_template('co2.html', error= "Error in your selection: Please select a single country")

df = emission_contributions()
country_df = df[df["country"] == selected_country]
Expand All @@ -73,8 +73,8 @@ def annual_emissions():
tree_abs = 25
number_of_trees = annual_emissions / tree_abs

return render_template('co2.html', result=str(annual_emissions) , selected_country=selected_country,
trees = number_of_trees)
return render_template('co2.html', result=str(annual_emissions) + str("kg of CO2") , selected_country=selected_country,
trees = number_of_trees, error= "Task Completed. You can try another country by going back to emissions.")



Expand Down
11 changes: 5 additions & 6 deletions Big-Job/templates/co2.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
</head>
<body>

<h4>Annual Emissions Results</h4>
<h1>Annual Emissions Results</h1>

<p> {{error}}</p>
<h3>Country: {{ selected_country }} </h3>
<h3>Emissions: {{ result }} </h3>
<h3>Needed trees: {{trees}}</h3>

<p>Country: {{ selected_country }} </p>
<p>Emissions: {{ result }} kg of CO2</p>
<p>Needed trees: {{trees}}</p>
<h3> Error in your selection: {{error}}</h3>
<h3>{{error}}</h3>
<br>
<button class="button" onclick="window.location.href='{{ url_for('emissions') }}'">Go back to emissions</button>
<hr>
Expand Down

0 comments on commit 9f46f83

Please sign in to comment.