Forums

request for PythonAnywhere to support python-eve module

I'm wondering if it's possible to have python-eve run within pythonanywhere-- I'm not having much luck getting things going...

Here's where that module/project resides: http://python-eve.org/

Why? I'd like to use flask as an API hub/app --- Eve is a great way to achieve that

The other odd issue (while I was trying to get Eve up and going) is the Flask app I had setup (in v2.7) kept on launching into python3.4 (from Save & Run on my flask_app.py file)...What's up with that?

Thanks, -Doug Jr.

Since eve is based on Flask and can use MySQL as a backend it should work fine on PythonAnywhere. However, I see that their docs say it's "powered by" redis (among other things). I couldn't tell from their docs whether redis is a hard requirement or something that you can use for some features. If it's a hard requirement, then eve will not currently work on PythonAnywhere. If it only powers some features then you'll just lose those features running it on PythonAnywhere.

As for why you get Python 3.4 as when you run the file: that's the default version of Python for save and run. You can change it by using a shebang in your file. However, if you're trying to run flask_app.py, you're probably misunderstanding what you need to do to get a web app working on PythonAnywhere. Have a look at this page in particular the section titled "Do not use app.run()"

A couple things to look out for:

  1. don't use app.run (or if you want to keep it, then put it inside of an if __name__ == '__main__' block)
  2. wire up the your app to uWSGI like you would for flask apps. ie. from your-project import app as application

If you get that setup I believe it should work.

Regarding the save and run, it's because you can't really save and run a webapp. The save and run is more for one off scripts that you run on the console. We default that to python3 to encourage people to switch over (it's the future!). If you want we can change the defaults for you back to python2.7

First, Redis is not optional and the docs needs clarification indeed (see https://github.com/nicolaiarocci/eve/issues/889).

As @glenn points out, following Setting up Flask applications on PythonAnywhere does the job for Eve too, obviously, with small adjustments:

  1. pip install eve

  2. Change the code to switch the minimal Flask to minimal Eve app.

  3. Create settings.py next to your main app script (check the minimal Eve app again for minimal sample).

  4. Finally, an important difference to Flask setup on PA:

    • Go to Dashboard > Web > your app.
    • Scroll to Code section
    • Change "Working directory:" location from your HOME /home/<username> (default) to root folder of your app, e.g. /home/<username>/myeveapp.

The last step is required in order to make Eve find the settings.py file.

Otherwise, expect to see in yourdomain.error.log file error like this:

eve.exceptions.ConfigException: DOMAIN dictionary missing or wrong.

I hope it helps.

Thanks! I'm sure that will help other people working on this.