-1

My small calculator app using Python and Flask works fine on the local desktop, but when I deployed to Heroku, it can work great for 3-6 calculations, then gives "internal server error". Pushing back button will sometimes allow a few more calculations, but then error occurs again. I have tested on iPhone, Windows desktop, and iPad (all of which my brother needs to work).

App address: https://woodcraft-bfc.herokuapp.com/

GitHub for code and files used for the app (am deploying app through GitHub): https://github.com/helpmerick/board-feet

Heroku log file text:

2020-08-23T18:08:44.907813+00:00 app[web.1]:     return self.view_functions[rule.endpoint](**req.view_args)
2020-08-23T18:08:44.907814+00:00 app[web.1]:   File "/app/board-feet.py", line 33, in CalculateNum
2020-08-23T18:08:44.907814+00:00 app[web.1]:     total = total
2020-08-23T18:08:44.907814+00:00 app[web.1]: NameError: name 'total' is not defined
2020-08-23T18:08:44.909289+00:00 app[web.1]: 10.150.246.196 - - [23/Aug/2020:18:08:44 +0000] "POST / HTTP/1.1" 500 290 "https://woodcraft-bfc.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36"
2020-08-23T18:08:44.911275+00:00 heroku[router]: at=info method=POST path="/" host=woodcraft-bfc.herokuapp.com request_id=8449a472-b1e2-4ca1-b800-6f1bf598634d fwd="69.244.31.219" dyno=web.1 connect=0ms service=15ms status=500 bytes=470 protocol=https
2020-08-23T18:08:48.115993+00:00 app[web.1]: fill in all fields
2020-08-23T18:08:48.116195+00:00 app[web.1]: 96   9   1
2020-08-23T18:08:48.117883+00:00 app[web.1]: 10.150.246.196 - - [23/Aug/2020:18:08:48 +0000] "POST / HTTP/1.1" 200 3642 "https://woodcraft-bfc.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36"
2020-08-23T18:08:48.119712+00:00 heroku[router]: at=info method=POST path="/" host=woodcraft-bfc.herokuapp.com request_id=e4199448-07a5-426a-90c4-2c25bb862175 fwd="69.244.31.219" dyno=web.1 connect=0ms service=4ms status=200 bytes=3884 protocol=https
2020-08-23T18:10:30.586204+00:00 heroku[router]: at=info method=POST path="/" host=woodcraft-bfc.herokuapp.com request_id=784a2f0e-91db-4e12-8e29-6521cacc21a1 fwd="69.244.31.219" dyno=web.1 connect=18ms service=13ms status=200 bytes=3889 protocol=https
2020-08-23T18:10:30.574701+00:00 app[web.1]: fill in all fields
2020-08-23T18:10:30.574857+00:00 app[web.1]: 96   9   1
2020-08-23T18:10:30.576635+00:00 app[web.1]: 10.9.251.250 - - [23/Aug/2020:18:10:30 +0000] "POST / HTTP/1.1" 200 3647 "https://woodcraft-bfc.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36"
2020-08-23T18:10:47.438566+00:00 app[web.1]: fill in all fields
2020-08-23T18:10:47.438807+00:00 app[web.1]: 144   25   3.25

Thank you for any insight you might have.

Rick
  • 9
  • 3
  • 2
    Please include the code as part of the question. Code linked to may change or the link may go stale. Either ruins the purpose of stackoverflow, which is to build up questions and answers – Dave W. Smith Aug 23 '20 at 19:59

1 Answers1

0

That attempt to use global for shared state kinda, sorta works in the development environment, but fails when an app is deployed to run in multiple processes. In your case, a POST is getting routed to a different process than the one that did the GET-time initialization.

The common ways of persisting state across requests are files on disk, browser sessions, and a database of some flavor.

Dave W. Smith
  • 24,318
  • 4
  • 40
  • 46
  • Thanks for the feedback. That makes sense. I will research how to implement the calculator with a different method for collecting the input. – Rick Aug 24 '20 at 02:40