Skip to content

cj-zeiger/eConnect-backend

Repository files navigation

eConnect Backend

The backend for eConnect is a Python Flask app that creates an API for the iOS app to use. It's database uses sqlite3 and has 2 tables, 'users' and 'interactions'. The backend also implements an administration panel that is served by Flask. The admin panel can start and stop the service aswell as clear the database.

##Installation ###Clone this repository using your ISID

git clone https://<ISID>@stash.merck.com/scm/ec/econnect_backend.git

###sqlite3 Make sure the *nix enviroment you are installing on has the latest version of sqlite3. ###Flask (Taken from Flask documentation)

  1. Before we install Flask, we need to make sure virtualenv is installed. (User whichever package manager is availbile)
sudo easy_install virtualenv

Then init a virtual environment

$ mkdir myproject
$ cd myproject
$ virtualenv venv
New python executable in venv/bin/python
Installing distribute............done.

And activate it

$ . venv/bin/activate
  1. Using pip, install the latest version of Flask
pip install Flask

###Other python dependencies

  1. Using pip, install other python dependencies
+Flask-Bcrypt==0.6.2
+Flask-Login==0.2.11
+Flask-WTF==0.12
+gunicorn==19.3.0
+itsdangerous==0.24
+Jinja2==2.7.3
+MarkupSafe==0.23
+python-bcrypt==0.3.1
+Werkzeug==0.10.4
+wheel==0.24.0
+WTForms==2.0.2

##Running and other configuration changes ###DEBUG By default, the DEBUG flag is turned on. This is good for development, but needs to be off when running in a production environment for security reasons.

app.config.update(dict(
    DATABASE = os.path.join(app.root_path, 'database.db'),
    DEBUG = True
))

Changes to

app.config.update(dict(
    DATABASE = os.path.join(app.root_path, 'database.db'),
    DEBUG = False
))

in server.py ###Running To start the service, invoke gunicorn server:app in the root of the project. The output should tell you where the service can be reached.

###Admin Panel password The username for the admin panel is admin, and for debugging purposes, the password is admin.

To change the password, do the following.

  1. Load up the virtual environment in the root directory of this project.
  2. Enter the python shell using python. You should now see the >>> prompt.
  3. Import the function we need. from flask.ext.bcrypt import generate_password_hash
  4. Now use that function subsituting in the new password. generate_password_hash('<new_password>')
  5. Copy the output of that function to your clipboard. Find the login function def login(): and replace the long random string that is the first parameter of check_password_hash() with the new hash you just generated.
  6. Restart the server.

##TODO #Important! +Right now, when data is cleared, the iOS app on client's phones are getting their data cleared. We need to implement some sort of event ID so that if a client connects to the server and has and old even ID, it will know that it has to clear its local data as it would not longer be valid. In the app's current state, users would have to uninstall and reinstall between evens to manually clear their local data.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published