Forums

Trouble getting second function output to display in HTML

I am creating a small calculation application. I got the basic function working in the first section of my html, but I can't for the life of me get it to display for the second section. I am very new to Python, Flask and programming in general. I am 100% surprised that I was able to get this far.

Section 1

PV1 > PV2

TEXT BOX

TEXT BOX

Section 2 (same backend calculations as Section 1)

PV2 > PFC

TEXT BOX

TEXT BOX

Section 3

Submit

Reset

Section 1 Info output

Section 2 Info Output (Not displaying)

Link to website: https://waiver-calculator-testing.uk.r.appspot.com/

Link to GitHub: https://github.com/SethBashamDev/waiver_cal

Add some logging to your code to see what is happening to it (on PythonAnywhere, prints to stderr will appear in your web app error logs). You should check things like:

  • is the code running in the order that you expect it to?
  • is there some condition that might be causing an early exit?
  • do your variables contain the values that you expect?

I am unsure how to add logging to my web app. I will look into it though and try to troubleshoot it. Thank you. Is it possible to also take variables from my function and add them into my HTML? eg. {{ variable }}

You can add simple print calls in your web app code. If you want the logging to appear in the error log, you need to redirect it there (code sample below), otherwise it will be shown in the server log.

# redirecting prints to error log
import sys

print("logging message", file=sys.stderr)

Alternatively you could use more advanced logging module.