Forums

How to host app that has already been written

Hey I've written an app already using Flask but I dont have any idea how to deploy it. Everything I do related to flask on PythonAnywhere involves creating a new app and editing it through the online editor. How could I deploy files from my own computer

There are three ways you can do this:

  1. Use the existing Dropbox integration to get it from your computer.

  2. Use a repositary like like github or bitbucket. You then 'push' from your local machine to the repository, and then 'pull' from PythonAnywhere.

  3. You could also just zip or tar the app on your development machine, and then upload the file. (Go to the 'files' tab and at the very bottom of the screen you will see an upload file button.)

Developers would recommend (2), as you get version tracking and a proper separation between development and production environments. (3) is by far the simplest.

Additionally -- to hook up your existing code to the PythonAnywhere web app system, just select "Manual configuration" when setting up a new app. That will generate a file /var/www/lolaznboy_pythonanywhere_com_wsgi.py, which contains comments and example code for hooking up various kinds of frameworks, including Flask, which you can modify to point to your app once you've uploaded it using one of the techniques rcs1000 suggests.

The generated "manual configuration" file does not have comments and examples for flask. Is there anywhere to find example files on how to set up a pre written flask app using the drop box?

Here's a sample Flask WSGI file -- I've put the bits you'll need to change in capitals.

import sys

project_home = '/home/YOURUSERNAME/PATH_TO_FOLDER_CONTAINING_YOUR_FLASK_APP'
if project_home not in sys.path:
    sys.path = [project_home] + sys.path

from YOUR_FLASK_MODULE import app as application