Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying flask site/application on pythonanywhere.com

I have a working sample site with the file system as such (https://github.com/alvations/APE):

APE
    \app
        \templates
            base.html
            index.html
            instance.html
        __init__.py
        hamlet.py
    config.py
    run.py

I have created a flask project on https://www.pythonanywhere.com and the file system is as such:

/home/alvations/
    /Dropbox/
    /mysite/
        /templates
            base.html
            index.html
            instance.html
        flask_app.py
    /web2py/

enter image description here

Where do I place my run.py in my pythonanywhere project?

How do I use the same file structure as my the project in my Github on pythonanywhere?

like image 522
alvas Avatar asked Nov 17 '14 12:11

alvas


Video Answer


1 Answers

PythonAnywhere dev here -- you don't need a run.py on PythonAnywhere. The code that normally goes in there is to run a local Flask server that can serve your app -- that's all handled for you by our system.

Instead, you need to change the WSGI file (linked from the "Web" tab) to import the appropriate application module. So, because the sample site you have on github does

from app import app
app.run(debug=True)

...on PythonAnywhere in the WSGI file you'll need to do this:

from app import app as application

One thing to be aware of -- if I'm understanding your file listings above correctly, you don't have all of the github app installed -- only the templates. You'll need __init__.py, hamlet.py, and config.py, and they'll need to be in the same directory structure as the original.

like image 70
Giles Thomas Avatar answered Oct 03 '22 09:10

Giles Thomas