Forums

Flask & the default Pythonanywhere Web - Code: Working Directory default

Pythonanywhere sets the default "Working directory" to "/home/username". I tested out a single file app; with this set-up, everything works:

.

│──  app

│   │──  templates

│    │──  static

│   └──  app.py

It knows where the static and template files are and all is well. But once I got to this point

.

├── app

│   ├── __init__.py

│   └── views

│       ├── __init__.py

│       ├── workout.py

│       └── workout_log.py

├── requirements.txt

├── run.py

├── schema.db

├── static

│   ├── scripts.js

│   ├── styles.css

│   └── workout_log.js

├── templates

 │   ├── 404.html

│    ├── base.html

│    ├── registration.html

 │   ├── workout-log.html

 │   └── workout.html

where the "Flask=app(name)'" was in the "app/init.py" file, this got weird and i had to move the "static" and "templates" folders up out of my app folder into "/home/username/". Setting "Working directory" to "/home/__username/app" fixed it (lost a few hours figuring it thought...). <br/> <br/> <br/> tl;dr: Why cant my flask app see my templates and static folders when I start breaking the code up? Why does setting "Working directory" to my app folder fix it?

[edited by admin: formatting]

shouldn't the templates folder be inside of your apps folder?

Honestly yeah, probably. They'd been working where they were so i never thought about them, but logically only my config and run.py really have any business at the root of my project folder