Reputation: 9617
I have python flask app which is written on windows. I am trying to deploy it using pythonanywhere.com hosting.
I have following structure:
app.py - my main application
-templates - here I have .html files
-default - here I have img, js, css subfolders.
So I have a confusion with files structure on linux systems. For example this is filestructure on pythonanywhere.com
> .bashrc 2015-02-19 17:55 546 bytes
> .gitconfig 2015-02-19 17:55 266 bytes
> .profile 2015-02-19 17:55 79 bytes
> .pythonstartup.py 2015-02-19 17:55 77 bytes
> .vimrc 2015-02-19 17:55 4.4 KB
> README.txt
So where should I put up my files? There on hosting?
Upvotes: 1
Views: 383
Reputation: 16071
I recommend a folder structure like this:
home
└── yourusername
└── myflaskapp
├── app.py
├── default
│ ├── css
│ ├── img
│ └── js
└── templates
└── index.html
On PythonAnywhere, you can go to the "Files" tab to create folders and upload files, one by one. If you have lots and lots of files, you might want to check out the guide to getting files in and out of PythonAnywhere
Once you've got your files uploaded, you'll want to do the following:
/home/yourusername/myflaskapp
to the sys.pathfrom app import app as application
(check out this guide if you need help with sys.path / import error issues)Hit reload, and you should see your web app.
Then to get the css and javascript working, you'll probably want to set up a static files mapping.
/static/
(or maybe /default/
, it depends on what you put in your templates), /home/yourusername/myflaskapp/default
.Upvotes: 2