Skip to content

Commit

Permalink
added documentation, removed SQLAlchemy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Hanif committed Nov 9, 2019
1 parent 5ded36c commit 7b90e1f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
27 changes: 25 additions & 2 deletions install/development_setup
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
ssh -i ~/Downloads/DNS.pem [email protected]
# Install Packages
sudo apt-get update
sudo apt-get install python3-pip
sudo apt-get install python3-venv
sudo apt-get install postgresql-server-dev-10

git clone https://github.com/zhanif3/818_search.git

# First, install the needed python environnment
virtenv env
cd 818_search
python3 -m venv env

# Run the virtual environment
source env/bin/activate

# Install needed python packages
pip install pipfile
(env)$ pip install flask
(env)$ pip install psycopg2


# Set up the database (DO NOT DO THIS ON AWS SERVER)
# sudo -u postgres psql
sudo -u postgres createuser --interactive
818project, y
sudo -u postgres createdb sammy
sudo adduser sammy
sudo -i -u sammy
psql

# What DB am I connected to?
\conninfo
18 changes: 6 additions & 12 deletions src/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from flask import Flask

from flask.ext.sqlalchemy import SQLAlchemy
import psycopg2
import os

app = Flask(__name__)
Expand All @@ -10,16 +9,6 @@
POSTGRES_URL = "127.0.0.1:5432"
POSTGRES_DB = "project"

DB_URL = 'postgresql+psycopg2://{user}:{pw}@{url}/{db}'.format(user=POSTGRES_USER,pw=POSTGRES_PW,url=POSTGRES_URL,db=POSTGRES_DB)

app.config['SQLALCHEMY_DATABASE_URI'] = DB_URL

db = SQLAlchemy(app)

class Experiment(db.Model):
id = db.Column(db.Integer, primary_key=True)
experiment_data = db.Column(db.String(200), unique=False, nullable=True)

@app.route('/upload', methods=['GET', 'POST'])
def upload():
if flask.request.method == 'POST':
Expand All @@ -44,3 +33,8 @@ def hello():

if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
# Connect to an existing database
conn = psycopg2.connect("dbname=test user=postgres")

# Open a cursor to perform database operations
cur = conn.cursor()

0 comments on commit 7b90e1f

Please sign in to comment.