Question

run time error in app platform - "workspace" directory is getting added

I could successfully deploy python/flask app on Apps Platform.

Now its giving runtime error

app runtime log error: FileNotFoundError: [Errno 2] No such file or directory: ‘/workspace/static/flora_title/Anacardiaceae_Buchanania cochinchinensis_1_Title1.JPG’

so it looks like the “workspace” directory is getting added to my html static data paths, which i don’t expect.

Request you to provide the solution

Runtime Log as below:

[onefloracdn] [2022-05-03 17:21:01] [2022-05-03 17:21:01 +0000] [1] [INFO] Starting gunicorn 20.1.0 [onefloracdn] [2022-05-03 17:21:01] [2022-05-03 17:21:01 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1) [onefloracdn] [2022-05-03 17:21:01] [2022-05-03 17:21:01 +0000] [1] [INFO] Using worker: sync [onefloracdn] [2022-05-03 17:21:01] [2022-05-03 17:21:01 +0000] [16] [INFO] Booting worker with pid: 16 [onefloracdn] [2022-05-03 17:21:01] OpenBLAS WARNING - could not determine the L2 cache size on this system, assuming 256k [onefloracdn] [2022-05-03 17:21:30] [2022-05-03 17:21:30,414] ERROR in app: Exception on / [GET] [onefloracdn] [2022-05-03 17:21:30] Traceback (most recent call last): [onefloracdn] [2022-05-03 17:21:30] File “/workspace/.heroku/python/lib/python3.10/site-packages/flask/app.py”, line 2077, in wsgi_app [onefloracdn] [2022-05-03 17:21:30] response = self.full_dispatch_request() [onefloracdn] [2022-05-03 17:21:30] File “/workspace/.heroku/python/lib/python3.10/site-packages/flask/app.py”, line 1525, in full_dispatch_request [onefloracdn] [2022-05-03 17:21:30] rv = self.handle_user_exception(e) [onefloracdn] [2022-05-03 17:21:30] File “/workspace/.heroku/python/lib/python3.10/site-packages/flask/app.py”, line 1523, in full_dispatch_request [onefloracdn] [2022-05-03 17:21:30] rv = self.dispatch_request() [onefloracdn] [2022-05-03 17:21:30] File “/workspace/.heroku/python/lib/python3.10/site-packages/flask/app.py”, line 1509, in dispatch_request [onefloracdn] [2022-05-03 17:21:30] return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) [onefloracdn] [2022-05-03 17:21:30] File “/workspace/species_visualization.py”, line 37, in index [onefloracdn] [2022-05-03 17:21:30] return render_template(“HomePage.html”, all_speciesj = all_speciesj) [onefloracdn] [2022-05-03 17:21:30] File “/workspace/.heroku/python/lib/python3.10/site-packages/flask/templating.py”, line 148, in render_template [onefloracdn] [2022-05-03 17:21:30] return _render( [onefloracdn] [2022-05-03 17:21:30] File “/workspace/.heroku/python/lib/python3.10/site-packages/flask/templating.py”, line 128, in _render [onefloracdn] [2022-05-03 17:21:30] rv = template.render(context) [onefloracdn] [2022-05-03 17:21:30] File “/workspace/.heroku/python/lib/python3.10/site-packages/jinja2/environment.py”, line 1291, in render [onefloracdn] [2022-05-03 17:21:30] self.environment.handle_exception() [onefloracdn] [2022-05-03 17:21:30] File “/workspace/.heroku/python/lib/python3.10/site-packages/jinja2/environment.py”, line 926, in handle_exception [onefloracdn] [2022-05-03 17:21:30] raise rewrite_traceback_stack(source=source) [onefloracdn] [2022-05-03 17:21:30] File “/workspace/templates/HomePage.html”, line 80, in top-level template code [onefloracdn] [2022-05-03 17:21:30] <img src=“{{url_for(‘static’, filename=‘flora_title/’ + species_row[counter.value].File_Name) + ‘?tr=ot-overlays%20made%20easy,ots-45,otc-00FFFF,otw-400’}}” alt=“{{species_row[counter.value].Botanical_name}}” style=“width:100%;height:150px;object-fit: contain;”> [onefloracdn] [2022-05-03 17:21:30] File “/workspace/.heroku/python/lib/python3.10/site-packages/flask_cdn.py”, line 54, in url_for [onefloracdn] [2022-05-03 17:21:30] values[‘t’] = int(os.path.getmtime(path)) [onefloracdn] [2022-05-03 17:21:30] File “/workspace/.heroku/python/lib/python3.10/genericpath.py”, line 55, in getmtime [onefloracdn] [2022-05-03 17:21:30] return os.stat(filename).st_mtime [onefloracdn] [2022-05-03 17:21:30] FileNotFoundError: [Errno 2] No such file or directory: ‘/workspace/static/flora_title/Anacardiaceae_Buchanania cochinchinensis_1_Title1.JPG’ [onefloracdn] [2022-05-03 17:21:30] 10.244.35.126 - - [03/May/2022:17:21:30 +0000] “GET / HTTP/1.1” 500 290 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Safari/537.36 Edg/101.0.1210.32”


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
July 23, 2022

Hello,

Do your static files actually exist on the GitHub repository that you are trying to deploy?

Usually, it is recommended to use Spaces for storing your static files when deploying to the App Platform as the storage is ephemeral.

Also, here is another quick video on how to deploy a Flask app to the DiugitalOcean App Platform:

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up