From f0ccc3f023ae0ec539efd5846ef82d88f65eece9 Mon Sep 17 00:00:00 2001 From: kaushik Visvanathan Date: Sun, 9 Apr 2017 11:13:48 -0400 Subject: [PATCH 01/11] created rest api folder --- rest_api/.DS_Store | Bin 0 -> 6148 bytes rest_api/restful.py | 74 ++++++++++++++++++++++++++++++++++ rest_api/templates/.DS_Store | Bin 0 -> 6148 bytes rest_api/templates/index.html | 8 ++++ 4 files changed, 82 insertions(+) create mode 100644 rest_api/.DS_Store create mode 100644 rest_api/restful.py create mode 100644 rest_api/templates/.DS_Store create mode 100644 rest_api/templates/index.html diff --git a/rest_api/.DS_Store b/rest_api/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a5f3f66d4b2acb2c602c68d321deaf01fdff7787 GIT binary patch literal 6148 zcmeHKOHRWu5FNJ_YSm4bEPaLEAgaO%qV7RSRgjV99%miN#CkX`$Q(~p*86o)woNzk_Kx4k0Drq1 zI?{' % self.username + + +# Replace app.routes with desired API endpoint +# username parameter needs to be replaced with table column name +@app.route('/', methods=['GET']) +def test(): + return jsonify({'message': 'It works!'}) + + +@app.route('/api/backpage/entities', methods=['GET']) +def test(): + entities = User.query.filter_by(username='entity').all() + return jsonify({'Entities': [entities]}) + + +@app.route('/api/backpage/entities/get/', methods=['GET']) +def test(): + entity = User.query.filter_by(id=entity_id).all() + return jsonify({'Entities': [entity]}) + + +@app.route('/api/backpage/entities/get/', methods=['GET']) +def test(): + entity = User.query.filter(User.email.endswith(email)).all() + return jsonify({'Entity': entity}) + + +@app.route('/api/backpage/cities/get/', methods=['GET']) +def test(): + entity = User.query.filter(User.query.filter_by(username=city).all() + return jsonify({'Entity': entity}) + + +""" +testlist = {'Test1': 'Test1 works', 'Test2': 'Test2 works', 'Test3': 'Test3 works'} +capitals = [{'name': 'Austin'}, {'name': 'Tallahassee'}, {'name': 'Sacramento'}] + +TEST ROUTES +@app.route('/tests', methods=['GET']) +def returnnumbers(): + return jsonify({'Alltests': testlist}) + + +@app.route('/lang/', methods=['GET']) +def returncapital(name): + capital = [capital for capital in capitals if capital['name'] == name] + return jsonify({'capital': capital[0]}) +""" + + +if __name__ == "__main__": + app.run(debug=True, port = 8000) \ No newline at end of file diff --git a/rest_api/templates/.DS_Store b/rest_api/templates/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 + + Database API + + + + + \ No newline at end of file From 1ad4edde2f74c13c1bdbe95c5a4f9fe2e0c33a64 Mon Sep 17 00:00:00 2001 From: kaushik Visvanathan Date: Sun, 16 Apr 2017 19:22:41 -0400 Subject: [PATCH 02/11] Configured local db for rest api --- rest_api/models.py | 37 ++++++++++++++++++++++++++++++++ rest_api/restful.py | 52 ++------------------------------------------- rest_api/routes.py | 39 ++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 50 deletions(-) create mode 100644 rest_api/models.py create mode 100644 rest_api/routes.py diff --git a/rest_api/models.py b/rest_api/models.py new file mode 100644 index 0000000..3c1c878 --- /dev/null +++ b/rest_api/models.py @@ -0,0 +1,37 @@ +import restful +from flask_sqlalchemy import SQLAlchemy +from healthcheck import HealthCheck, EnvironmentDump + +db = SQLAlchemy(app) + +# wrap the flask app and give a heathcheck url +health = HealthCheck(app, "/healthcheck") + +def health_database_status(): + is_database_working = True + output = 'database is ok' + + try: + session = db.session() + session.execute('SELECT * from backpageemail') + except Exception as e: + output = str(e) + is_database_working = False + + print output + return is_database_working, output + + +class Post(db.Model): + id = db.Column(db.Integer, primary_key=True) + backpagepostid = db.Column('backpagepostid', db.Integer, unique=True) + title = db.Column('title', db.String(120)) + body = db.Column('body', db.Unicode) + textsearch = db.Column('textsearch', db.String(80)) + # email = db.Column(db.String(120), unique=True) + + # def __init__(self, backpagepostid, title, body, textsearch): + # self.backpagepostid = backpagepostid + # self.title = title + # self.body = body + # self.textsearch = textsearch diff --git a/rest_api/restful.py b/rest_api/restful.py index 7298062..8f005ba 100644 --- a/rest_api/restful.py +++ b/rest_api/restful.py @@ -1,56 +1,8 @@ from flask import Flask, jsonify, request, render_template -from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) -app.config.from_object('config') -app.config['SQLALCHEMY_DATABASE_URI'] = 'Wherever Database is running' +app.config['SQLALCHEMY_DATABASE_URI'] = "postgresql://localhost:5432/crawler" app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False -db = SQLAlchemy(app) - - -# Needs to be updated for this database -class User(db.Model): - id = db.Column(db.Integer, primary_key=True) - username = db.Column(db.String(80), unique=True) - email = db.Column(db.String(120), unique=True) - - def __init__(self, username, email): - self.username = username - self.email = email - - def __repr__(self): - return '' % self.username - - -# Replace app.routes with desired API endpoint -# username parameter needs to be replaced with table column name -@app.route('/', methods=['GET']) -def test(): - return jsonify({'message': 'It works!'}) - - -@app.route('/api/backpage/entities', methods=['GET']) -def test(): - entities = User.query.filter_by(username='entity').all() - return jsonify({'Entities': [entities]}) - - -@app.route('/api/backpage/entities/get/', methods=['GET']) -def test(): - entity = User.query.filter_by(id=entity_id).all() - return jsonify({'Entities': [entity]}) - - -@app.route('/api/backpage/entities/get/', methods=['GET']) -def test(): - entity = User.query.filter(User.email.endswith(email)).all() - return jsonify({'Entity': entity}) - - -@app.route('/api/backpage/cities/get/', methods=['GET']) -def test(): - entity = User.query.filter(User.query.filter_by(username=city).all() - return jsonify({'Entity': entity}) """ @@ -71,4 +23,4 @@ def returncapital(name): if __name__ == "__main__": - app.run(debug=True, port = 8000) \ No newline at end of file + app.run(debug=True, port = 8000) diff --git a/rest_api/routes.py b/rest_api/routes.py new file mode 100644 index 0000000..d475ab4 --- /dev/null +++ b/rest_api/routes.py @@ -0,0 +1,39 @@ +from models import Post, db + +health_database_status() +py = Post() +p = py.query.all() + +@app.route('/', methods=['GET']) +def test(): + return jsonify({'message': 'It works!'}) + + +@app.route('/api/backpage/posts', methods=['GET']) +def get_posts(): + posts = User.query.all() + return jsonify({'Posts': [posts]}) + + +# @app.route('/api/backpage/entities', methods=['GET']) +# def test1(): +# entities = User.query.filter_by(username='entity').all() +# return jsonify({'Entities': [entities]}) + + +# @app.route('/api/backpage/entities/get/', methods=['GET']) +# def test2(): +# entity = User.query.filter_by(id=entity_id).all() +# return jsonify({'Entities': [entity]}) + + +# @app.route('/api/backpage/entities/get/', methods=['GET']) +# def test3(): +# entity = User.query.filter(User.email.endswith(email)).all() +# return jsonify({'Entity': entity}) + + +# @app.route('/api/backpage/cities/get/', methods=['GET']) +# def test(): +# entity = User.query.filter(User.query.filter_by(username=city).all() +# return jsonify({'Entity': entity}) From bdfa9abd52e75980316636acc4debc084fbf0ac7 Mon Sep 17 00:00:00 2001 From: kaushik Visvanathan Date: Sun, 16 Apr 2017 19:55:29 -0400 Subject: [PATCH 03/11] merged flask app back into one file --- rest_api/models.py | 37 --------------------- rest_api/restful.py | 78 ++++++++++++++++++++++++++++++++++++++------- rest_api/routes.py | 39 ----------------------- 3 files changed, 66 insertions(+), 88 deletions(-) delete mode 100644 rest_api/models.py delete mode 100644 rest_api/routes.py diff --git a/rest_api/models.py b/rest_api/models.py deleted file mode 100644 index 3c1c878..0000000 --- a/rest_api/models.py +++ /dev/null @@ -1,37 +0,0 @@ -import restful -from flask_sqlalchemy import SQLAlchemy -from healthcheck import HealthCheck, EnvironmentDump - -db = SQLAlchemy(app) - -# wrap the flask app and give a heathcheck url -health = HealthCheck(app, "/healthcheck") - -def health_database_status(): - is_database_working = True - output = 'database is ok' - - try: - session = db.session() - session.execute('SELECT * from backpageemail') - except Exception as e: - output = str(e) - is_database_working = False - - print output - return is_database_working, output - - -class Post(db.Model): - id = db.Column(db.Integer, primary_key=True) - backpagepostid = db.Column('backpagepostid', db.Integer, unique=True) - title = db.Column('title', db.String(120)) - body = db.Column('body', db.Unicode) - textsearch = db.Column('textsearch', db.String(80)) - # email = db.Column(db.String(120), unique=True) - - # def __init__(self, backpagepostid, title, body, textsearch): - # self.backpagepostid = backpagepostid - # self.title = title - # self.body = body - # self.textsearch = textsearch diff --git a/rest_api/restful.py b/rest_api/restful.py index 8f005ba..fe449d0 100644 --- a/rest_api/restful.py +++ b/rest_api/restful.py @@ -1,25 +1,79 @@ from flask import Flask, jsonify, request, render_template +from flask_sqlalchemy import SQLAlchemy +from healthcheck import HealthCheck, EnvironmentDump + app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = "postgresql://localhost:5432/crawler" app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False +db = SQLAlchemy(app) + + +# wrap the flask app and give a heathcheck url +health = HealthCheck(app, "/healthcheck") + +def health_database_status(): + is_database_working = True + output = 'database is ok' + + try: + session = db.session() + session.execute('SELECT * from backpageemail') + except Exception as e: + output = str(e) + is_database_working = False + + print output + return is_database_working, output + + +class Post(db.Model): + id = db.Column(db.Integer, primary_key=True) + backpagepostid = db.Column('backpagepostid', db.Integer, unique=True) + title = db.Column('title', db.String(120)) + body = db.Column('body', db.Unicode) + textsearch = db.Column('textsearch', db.String(80)) + + + +health_database_status() +bp_data = Post() +p = bp_data.query.all() + + +@app.route('/', methods=['GET']) +def test(): + return jsonify({'message': 'It works!'}) + + +# @app.route('/api/backpage/posts', methods=['GET']) +# def get_posts(): +# posts = bp_data.query.all() +# return jsonify({'Posts': [posts]}) + +# @app.route('/api/backpage/entities', methods=['GET']) +# def test1(): +# entities = User.query.filter_by(username='entity').all() +# return jsonify({'Entities': [entities]}) + + +# @app.route('/api/backpage/entities/get/', methods=['GET']) +# def test2(): +# entity = User.query.filter_by(id=entity_id).all() +# return jsonify({'Entities': [entity]}) -""" -testlist = {'Test1': 'Test1 works', 'Test2': 'Test2 works', 'Test3': 'Test3 works'} -capitals = [{'name': 'Austin'}, {'name': 'Tallahassee'}, {'name': 'Sacramento'}] -TEST ROUTES -@app.route('/tests', methods=['GET']) -def returnnumbers(): - return jsonify({'Alltests': testlist}) +# @app.route('/api/backpage/entities/get/', methods=['GET']) +# def test3(): +# entity = User.query.filter(User.email.endswith(email)).all() +# return jsonify({'Entity': entity}) -@app.route('/lang/', methods=['GET']) -def returncapital(name): - capital = [capital for capital in capitals if capital['name'] == name] - return jsonify({'capital': capital[0]}) -""" +# @app.route('/api/backpage/cities/get/', methods=['GET']) +# def test(): +# entity = User.query.filter(User.query.filter_by(username=city).all() +# return jsonify({'Entity': entity}) if __name__ == "__main__": diff --git a/rest_api/routes.py b/rest_api/routes.py deleted file mode 100644 index d475ab4..0000000 --- a/rest_api/routes.py +++ /dev/null @@ -1,39 +0,0 @@ -from models import Post, db - -health_database_status() -py = Post() -p = py.query.all() - -@app.route('/', methods=['GET']) -def test(): - return jsonify({'message': 'It works!'}) - - -@app.route('/api/backpage/posts', methods=['GET']) -def get_posts(): - posts = User.query.all() - return jsonify({'Posts': [posts]}) - - -# @app.route('/api/backpage/entities', methods=['GET']) -# def test1(): -# entities = User.query.filter_by(username='entity').all() -# return jsonify({'Entities': [entities]}) - - -# @app.route('/api/backpage/entities/get/', methods=['GET']) -# def test2(): -# entity = User.query.filter_by(id=entity_id).all() -# return jsonify({'Entities': [entity]}) - - -# @app.route('/api/backpage/entities/get/', methods=['GET']) -# def test3(): -# entity = User.query.filter(User.email.endswith(email)).all() -# return jsonify({'Entity': entity}) - - -# @app.route('/api/backpage/cities/get/', methods=['GET']) -# def test(): -# entity = User.query.filter(User.query.filter_by(username=city).all() -# return jsonify({'Entity': entity}) From 3bc91847c54557c1d3740632965d76c64358672a Mon Sep 17 00:00:00 2001 From: kaushik Visvanathan Date: Tue, 18 Apr 2017 20:16:52 -0400 Subject: [PATCH 04/11] created routes for a couple of tables --- CREATE | 0 rest_api/models.py | 45 ++++++++++++++++++++++ rest_api/models.pyc | Bin 0 -> 3123 bytes rest_api/restful.py | 86 +++++++++++++++++++++++++++---------------- rest_api/restful.pyc | Bin 0 -> 4651 bytes 5 files changed, 100 insertions(+), 31 deletions(-) create mode 100644 CREATE create mode 100644 rest_api/models.py create mode 100644 rest_api/models.pyc create mode 100644 rest_api/restful.pyc diff --git a/CREATE b/CREATE new file mode 100644 index 0000000..e69de29 diff --git a/rest_api/models.py b/rest_api/models.py new file mode 100644 index 0000000..afde5c6 --- /dev/null +++ b/rest_api/models.py @@ -0,0 +1,45 @@ +from restful import db + + +class Backpagecontent(db.Model): + id = db.Column(db.Integer, primary_key=True) + backpagepostid = db.Column('backpagepostid', db.Integer, unique=True) + title = db.Column('title', db.String(120)) + body = db.Column('body', db.Unicode) + textsearch = db.Column('textsearch', db.String(80)) + + +class Backpageemail(db.Model): + backpagepostid = db.Column('backpagepostid', db.Integer, primary_key=True) + email = db.Column('name', db.String(30)) + + +class Backpageentities(db.Model): + enitity_id = db.Column('enitity_id', db.Integer, primary_key=True) + backpagepostid = db.Column('backpagepostid', db.Integer) + + +class Backpagephone(db.Model): + backpagepostid = db.Column('backpagepostid', db.Integer, primary_key=True) + number = db.Column('number', db.String(20)) + + +class Backpagepost(db.Model): + id = db.Column(db.Integer, primary_key=True) + pageid = db.Column('pageid', db.Integer, unique=True) + oid = db.Column('oid', db.Integer) + posterage = db.Column('posterage', db.SmallInteger) + postdate = db.Column('postdate', db.DateTime(timezone=True)) + backpagesiteid = db.Column('backpagesiteid', db.Integer) + + +class Backpagesite(db.Model): + id = db.Column(db.Integer, primary_key=True) + name = db.Column('name', db.String(120)) + + +class Crawler(db.Model): + id = db.Column(db.Integer, primary_key=True) + name = db.Column('name', db.String(32)) + version = db.Column('version', db.VARCHAR) + diff --git a/rest_api/models.pyc b/rest_api/models.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0b118db45d3792178b34e2b4644eb514e2586e70 GIT binary patch literal 3123 zcmc&$TW=dh6rQ!?TP|&?5}Hs^g^Gve0sLACR1wk#cmPF{6oFq>8}B5ZcrWhGIMlor z@f-L9{1S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page_content_id).all()) + + return jsonify({'data': [ + dict(id=c.id, postId=c.backpagepostid, title=c.title) + for c in contents + ]}) + + +@app.route('/api/backpage/cities/', methods=['GET']) +def get_all_cities(): + cities = (Backpagesite.query.all()) + # In case we want only names without id's + citynames = [c.name for c in cities] + + return jsonify({'data': [ + dict(id=c.id, city=c.name) + for c in cities + ]}) + + +@app.route('/api/backpage/phone/', methods=['GET']) +def get_all_numbers(): + numbers = (Backpagephone.query.all()) + + return jsonify({'data': [ + dict(backpagepostid=n.backpagepostid, number=n.number) + for n in numbers + ]}) + + +@app.route('/api/backpage/phone/', methods=['GET']) +def get_number(backpagepost_id): + numbers = (Backpagephone.query.filter_by(backpagepostid=backpagepost_id).all()) + + return jsonify({'numbers': [n.number for n in numbers]}) + + +@app.route('/api/backpage/phone/', methods=['GET']) +def getid_from_number(number): + ids = (Backpagephone.query.filter_by(number=number).all()) + + return jsonify({'backpagepost_ids': [i.backpagepostid for i in ids]}) + + +@app.route('/api/backpage/email/', methods=['GET']) +def get_email(backpagepost_id): + emails = (Backpageemail.query.filter_by(backpagepostid=backpagepost_id).all()) -# @app.route('/api/backpage/entities', methods=['GET']) -# def test1(): -# entities = User.query.filter_by(username='entity').all() -# return jsonify({'Entities': [entities]}) + return jsonify({'Emails': [i.email for i in emails]}) -# @app.route('/api/backpage/entities/get/', methods=['GET']) -# def test2(): -# entity = User.query.filter_by(id=entity_id).all() -# return jsonify({'Entities': [entity]}) +@app.route('/api/backpage/email/', methods=['GET']) +def getid_from_mail(email): + ids = (Backpageemail.query.filter_by(email=email).all()) + return jsonify({'backpagepost_ids': [i.backpagepostid for i in ids]}) -# @app.route('/api/backpage/entities/get/', methods=['GET']) -# def test3(): -# entity = User.query.filter(User.email.endswith(email)).all() -# return jsonify({'Entity': entity}) -# @app.route('/api/backpage/cities/get/', methods=['GET']) -# def test(): -# entity = User.query.filter(User.query.filter_by(username=city).all() -# return jsonify({'Entity': entity}) if __name__ == "__main__": diff --git a/rest_api/restful.pyc b/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`Z$d@E z0B`h@4BS9Sz?P1ZJ)NE4V1Wlq4rD=N5>8-``QBS>@@*X(P#!5yhjjX&;}}wcUM%G{ z4;3lV%rSq1M_z>aL?J{Km?(nBr+_;={g{Y+Bhyk5F!{#~E%)dYmYNWD=#AWx0_^g0UF`7QkIMOiAQP{!JuYmgj502sfr>^B- zIJv=3QP)yhHgGo0p|&ThiY)C#QkU&JKhZ+(-g|5$l8hPeBkoThew1OzTo&;ScgC<| z8=6$PIJvh9l}qox7WpT<2=4SG#yW^|)75Ol+Q>R7~W)T4lv$sp9RDb|5g1g`@D{ozoq^VzQ(?RyCC;T$G|c{mUIx-2W> z7bWdogwN|RZ^Gat;Jpv?G0dkh*rz0XHcCBI)v?H>HLVln9N+pDKl&)vw^8fl=yYA3 hQA?^`X{ZIY;54dDXTCXGS)N(0FE{u*D}VKd`WrQCDRlq< literal 0 HcmV?d00001 From b14ec643f7aa7a8838df5cf84ad6cad55b2b8a3e Mon Sep 17 00:00:00 2001 From: kaushik Visvanathan Date: Tue, 2 May 2017 20:41:27 -0400 Subject: [PATCH 05/11] added freetext search for backpagecontent table --- rest_api/.DS_Store | Bin 6148 -> 6148 bytes rest_api/__pycache__/models.cpython-35.pyc | Bin 0 -> 2425 bytes rest_api/__pycache__/restful.cpython-35.pyc | Bin 0 -> 5676 bytes rest_api/models.py | 4 ++- rest_api/models.pyc | Bin 3123 -> 0 bytes rest_api/restful.py | 34 ++++++++++++++++++-- rest_api/restful.pyc | Bin 4651 -> 0 bytes 7 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 rest_api/__pycache__/models.cpython-35.pyc create mode 100644 rest_api/__pycache__/restful.cpython-35.pyc delete mode 100644 rest_api/models.pyc delete mode 100644 rest_api/restful.pyc diff --git a/rest_api/.DS_Store b/rest_api/.DS_Store index a5f3f66d4b2acb2c602c68d321deaf01fdff7787..40dac61b950eeceaa89f5d9906968ecf370186f6 100644 GIT binary patch delta 87 zcmZoMXfc=|#>B`mu~2NHo}wrV0|Nsi1A_nqLk>eCLkUAFLvc>}#KPr_ER)YMiEZA; oB)qu~2NHo}wrx0|Nsi1A_nqLncFVPP$=ma(-^X=7o&Q8S6n(Yz)N= zB@Br`j3f;dhXEA%+>T_YKo0>O{hfI-zlbFV&_6)Lz_2+$WD7F@k8v|S diff --git a/rest_api/__pycache__/models.cpython-35.pyc b/rest_api/__pycache__/models.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d15033ab81e217a39e0a59cb33afbc88d7b1064b GIT binary patch literal 2425 zcmcIl-EJF27@f7fKVI8OibzRSr~*`#wk`MtP?eC1!Ua}Ty9j)<+IT1N#{1*WtV7+~ za?LYv%X9D+bIX-qfh*28V>^qwQfLvj_uKJz=4a2GZ_nKB^?dI^`=<+su|HYm(?a_Q zm;3`E#?N9YW0}Rq7PFqk4Hh@qFGx2Tx7cNay=k&>lRb-DEVeaZSAZ4(hsCZ2+zMa= z@L1f|K)V7s0DKmAG|;I4E`TnJdm89f01vp*yySVQI&+a^kywT^z8tBYvo$;~ zWSPXuS>(yf1y^>Nlqp}m0wvWtE8?Z{Oa7{qJQ9=X>J;fgu%o;%%%hBlq4L8pE8;~; z?QR&pTtulsM1!VqPKtDq<;wjI4{^bTY9z6sjZ>`=rWGzV-4}T>DPk_#ddRR8Nq!-G z{P~@UecW{TE9$?HT*&?`TF7ZKyGrC$lt<+>%KJ}?$sz+u**{&D(;`0=#U-EM?{Qux zha(Z4pC^+UX6;YQFNjHU#ruNGGK}U)9|U+Rznm{c6N^y+OIo~Z9awkq-M4hUUi)v* z@onv)Iw=H=b-k0uTlr08xK!?IjkVsxz*W7CW;~0MRPU3Z#~G;>ZR+YC+Jm4iy10uT zg&hjC(_)vx9tGN7@gah;%{<#JG@E&w@Q)B^21)aG!BS`HIUb?Q`)~w7RIp|`3>>w$ zWd~8pgiGb~9F1}rq9`;^{p^FlyMf`ycpyWwj@n(IAK<#CMwxnQ|BrlglpwFl=j4m* zjEfbi@(uzD68!oNsL1yT0Fv;UBW3D2{s!c2`PTLM9` z7@0IYj#-3uH>fc+Gtbtrx|{MKM_QM?Lk5Q8z#+p_vw%;v3FQK5!(%Dut?kreqL==>Yq zw}h4Z!}0TzZ;zjg$C##8-iH7l;gVE~MqWX=LEw*FI!ewLsX6oP@98|zXNERaLG~l4 iG;}5CZPP>R)=}P9<~)63VSprm-)r7!-?8y^=>9kNT(4^Y literal 0 HcmV?d00001 diff --git a/rest_api/__pycache__/restful.cpython-35.pyc b/rest_api/__pycache__/restful.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..426eda038ef3c543e201992d47d2f39d997f004e GIT binary patch literal 5676 zcmcIo|92C|5ud#~NtP^I27?{G3k)P8!6J|}4Rt8SHpDG)zF2vHUi$RTx|My_=_Gbf zfK_OJAg}4K{WJP6?XUf*|3ZH1%-*f6lhxO}xX9eHw>vvCJM)>D-CLNMDSUoC|7>9v z;9oHE%V7ULKJuvr;Nd?80YHaAok7Qfx&<8@>Na#7s5`)j!h#?Joh;O|@w*K{4mwj% zpMp*v>iKxofuI02qR&7u4fScw9s5P77fpW#>NCI@@L70^B1_<9ftO%^4!j(!cvI#j z4=Y^H5Y-9bdcrHfTh#C*c*wg5KLXU}fzQKR07gtsfj0x*EO;f@Wyqg-$o2%$5tq}N zH`3txQJQ)1P8pg7LvuP!vjE`qx zE*cT<^a3~H6{ZT?-#%UqntQx+P_fkXm)s4ay|q2wY^%~n_`(<6u*1V>z2E5}HM_Aj zSn73Uv@5uL9^9=~gKpCe_Hg9xr=Q%pU2O{YWx$16B({&&zTEigSz~>*w)$Xod!zCF zcbgB@#gUoXcdKiEY<%_g`sTyUwbk0@*IV0zVs%gJfGRcHP1+It9DL^RS;I%Z#0Ep? zjSiDH3=S?p1h9|r19)S>YYX-*@N7aLdlG&IPGm#70AdH&8ynbQ5h4d(>v>%5ImGG7 zGm0WyZ^K_~cp5Tz8fD-$K^oX=pkB*DBWJd1gIUjw+#Of)vMOZsGQ_d`rT0F_$%J*M_lDMUNw0yq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}VmeJ+k=3;rruap85w=2Ls>o9pc^~lKE0HBS;1|Np8zSR@`ze cmvO%Sg@5%u', methods=['GET']) +def get_search_results(search): + contents = (Backpagecontent.query.filter(Backpagecontent.title.contains(search)).all()) + + return jsonify({'data': [ + dict(id=c.id, postId=c.backpagepostid, title=c.title) + for c in contents if re.search(r'\b' + search + r'\b', c.title) + ]}) + + @app.route('/api/backpage/cities/', methods=['GET']) def get_all_cities(): cities = (Backpagesite.query.all()) @@ -59,6 +78,17 @@ def get_all_cities(): ]}) +@app.route('/api/backpage/cities/q=', methods=['GET']) +def search(testsearch): + cities = (Backpagesite.query.all()) + citynames = [c.name for c in cities] + + return jsonify({'data': [ + dict(id=c.id, city=c.name) + for c in cities if testsearch in c.name + ]}) + + @app.route('/api/backpage/phone/', methods=['GET']) def get_all_numbers(): numbers = (Backpagephone.query.all()) diff --git a/rest_api/restful.pyc b/rest_api/restful.pyc deleted file mode 100644 index 0699cbe2a5591600412361edefb61942d544a31b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4651 zcmc&%U31$+6um1uPU1RsL)(;oQKucibOyvXOeh`FB+v|PT9ojWnPL=a9V?b(SGz7` zrhN*(hF`-2|AZM{;hrlgj!S2F!Z`8u?&|K<>YQ`$t}1^l)c^eT&+h^%J~RCL8Gp_1 ziYVlNMKMvLXjf6<(5^#Cg?1~HRB5+L3LXx{GnCY5x0d%S6wgvJN4s;B%+v0CK3b)? zPCHtWK1D|yu0i1p=>{DvP*|f|`gGZu);4)O(`l%)j@8L9 z_N{KSILOx7Y=3ocH4b_@Icz%^JH_U%_G8;y>*=5`lQ+^QQ8q{uo!a$LGR!9*yt7~6&?mt-H{Csn5b!YRz*0yP|i`$cB@mhnv$Q_T5r(ff*`H_t!dM1j0 zrs(i0Sw#m9ME1;~rw$!dAaxd%`Zj%)s*)M6$of&b&ub?djO=h^J%Gj-5a~7>5@Ytb<$i5+X579%GQFt(Br;F@)VDo9b=L>M z2s9h_;i2sf(udj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added endpoint that returns results from joined tables --- rest_api/__pycache__/models.cpython-35.pyc | Bin 2425 -> 2592 bytes rest_api/__pycache__/restful.cpython-35.pyc | Bin 5676 -> 6149 bytes rest_api/models.py | 9 ++++----- rest_api/restful.py | 19 ++++++++++++------- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/rest_api/__pycache__/models.cpython-35.pyc b/rest_api/__pycache__/models.cpython-35.pyc index d15033ab81e217a39e0a59cb33afbc88d7b1064b..f91eb55b1ee3054e4d181e80bf34290897fae9ab 100644 GIT binary patch delta 1028 zcmZuwOK;Oa5Z<-pM_eZ4 zG|8D!PIv0eDkDdjGtJKvHbXi!SDw;(;i$0d_x6W=pAX~FcvXI;by|>r=$4x}Ph-J@ ze$?cL@}9P8&I3v@FJtX3U6J3lj~gX$BnA)tU?3(zm4WIisxl}SWRyXJE>KaHzcf$& z)K8k%F~LBUR(TBqS3v$%qNfLP@m%oM2Hr}tqGyZ9oT&%{=5$4&E}OL40IoVUJIOtq zwz?NbT-|=D{eTI?x}BKOLAcAsk0N}vYK}a!t2=XGPatFCqKYaFd<6pNKL@`;1$xrK zf5M^5FGhD0CImxua5l^(EC1;Pr@)vSDBKG{$=Bo>ZR@Yjj^|4ft2 zz&|=nEOr?AVbBvgfN4S9nZ5jO32bo#RN{6*e=v9+jd`C7v5YSJu|MY9LCD2Tl_B`R z9|v(X+6#tVV~89kRxgHJ#f_qy6Yvqb=^>9cibnLEsjihU+we uDAuHzU2Nm>3fwxyt->qtZh<9fXC?OiFlGk>zC|HJ^*pP4wr8l<@r=J8G`^ew delta 713 zcmZ`%&r2IY6rRbC%}%l#P_rg$YKW-{(KZrVO6freMo^GKRRldqH|`LlNg5_8v}X_A zgz_#udM*}v^x{9VH|eRM2aiGyeQ)#YU}TwZhxgw1%{SlfW#VztoHos$H{x%iela#E>i))Ht{BXl%#E_0 zdrx3w{Q^@ia^XuiqrF;Du$wsnu1l=}!<$6C@E#T{DyS0W?^E9?dFwR;Q8)UC-AQ(J_fm!%uxXQwn zZo_@#kf&fvUn%-mOySg6ojf+^kp2}@T;-8}j@-B6eQC(`B73FnwT;rYdi9*r5;m4e o3IDaeBeev-#aw|RRP?13IaXN$I#&_pi7V&|J0|QfKAMg1|9K^Si2wiq diff --git a/rest_api/__pycache__/restful.cpython-35.pyc b/rest_api/__pycache__/restful.cpython-35.pyc index 426eda038ef3c543e201992d47d2f39d997f004e..ff2295fed073a7f5ab752880b32741f17544e828 100644 GIT binary patch delta 606 zcmZ8dTWb?h5S}@kOS9R{Ce7ugmbP{kORH^aEo!~AP*Gb8LO`exL(N%oE8BLnv@s@B zX)E+i9l=*$6<;LaKM(}}L0o-662JH3by`PEA;>9|oBQ zISukG$QjrJfzl6|v2(3Q!WNjI@4gp!vbFDDM@-X?z)PHH9R?-h9DVD1inFvE`ij@6 zsJ_P=G!)L_0yV?G@HRcvK469x^y|1nhx$*vM+cEQu0A(@V}ZIx4f9lscG0Fs z#Jadmo&Ftks1omBlX8h|63mKtn)TfoBSA9fPd^WSk`1 z#(Zt<=$LjezhS$U?KSn=mbG_%~c1mvX z<|4g{B>lPsm2*8#>c?$m;ni}0@)5gTpY1c*^Eh@k0C{uA)ASzD1<4MpCL=0 zAw`cNMV}$XfFZ?@p_ze+F@=>OSkq|p5~e&RMybidtWy|uHm_jKVPrI$EXqEe(Qxxx z_7p}&hsi>m6Bw;0FXnu~=sCHEYa64_WM}SJM%T#;x&JbTOrFnklremADz7_Z;N-Qu zzZnxJujH#@jG3&$|Bo?iva&!0W7_070{e&NrI z^^==L%J{26?q&fJ3{28YMP8G)i77HFOuiv@V)9aP4MwBM=fovsx%ioQ_}Q6NSXH=y PkVl0ZNV0<=7Y`!<7$QV> diff --git a/rest_api/models.py b/rest_api/models.py index a539101..ef5b396 100644 --- a/rest_api/models.py +++ b/rest_api/models.py @@ -3,11 +3,10 @@ class Backpagecontent(db.Model): id = db.Column(db.Integer, primary_key=True) - backpagepostid = db.Column('backpagepostid', db.Integer, unique=True) + backpagepostid = db.Column('backpagepostid', db.Integer, db.ForeignKey('backpagepost.id'), unique=True) title = db.Column('title', db.Text(120)) body = db.Column('body', db.Unicode) textsearch = db.Column('textsearch', db.String(80)) - # phone = db.relationship('Backpagephone', backref='backpagecontent', lazy='dynamic') class Backpageemail(db.Model): @@ -21,9 +20,8 @@ class Backpageentities(db.Model): class Backpagephone(db.Model): - backpagepostid = db.Column('backpagepostid', db.Integer, primary_key=True) + backpagepostid = db.Column('backpagepostid', db.Integer, db.ForeignKey('backpagepost.id'), primary_key=True, ) number = db.Column('number', db.String(20)) - # post_id = db.Column(db.Integer, db.ForeignKey('Backpagecontent.backpagepostid')) class Backpagepost(db.Model): @@ -32,7 +30,8 @@ class Backpagepost(db.Model): oid = db.Column('oid', db.Integer) posterage = db.Column('posterage', db.SmallInteger) postdate = db.Column('postdate', db.DateTime(timezone=True)) - backpagesiteid = db.Column('backpagesiteid', db.Integer) + phone = db.relationship('Backpagephone', backref='backpagepost', lazy='dynamic') + content = db.relationship("Backpagecontent", backref='backpagepost', lazy='dynamic') class Backpagesite(db.Model): diff --git a/rest_api/restful.py b/rest_api/restful.py index 87df145..296035a 100644 --- a/rest_api/restful.py +++ b/rest_api/restful.py @@ -14,13 +14,7 @@ db = SQLAlchemy(app) -""" -Join below tables: -Backpagephone, Backpageemail and backpagesite -""" - - -# wrap the flask app and give a heathcheck url +# wrap the flask app and give a heathcheck url to make sure DB is ok health = HealthCheck(app, "/healthcheck") def health_database_status(): @@ -46,6 +40,7 @@ def test(): return jsonify({'message': 'It works!'}) +# Backpagecontent table API endpoints with integer params and text search - returns title, body, postid @app.route('/api/backpage/content/', methods=['GET']) def get_content(backpage_content_id): contents = (Backpagecontent.query.filter_by(id=backpage_content_id).all()) @@ -66,6 +61,7 @@ def get_search_results(search): ]}) +# Backpagesite table endpoints - returns all cities in table @app.route('/api/backpage/cities/', methods=['GET']) def get_all_cities(): cities = (Backpagesite.query.all()) @@ -89,6 +85,7 @@ def search(testsearch): ]}) +# Backpagephone table endpoints - returns phone numbers and postids @app.route('/api/backpage/phone/', methods=['GET']) def get_all_numbers(): numbers = (Backpagephone.query.all()) @@ -113,6 +110,7 @@ def getid_from_number(number): return jsonify({'backpagepost_ids': [i.backpagepostid for i in ids]}) +# Backpageemail endpoints - returrns emails and post ids @app.route('/api/backpage/email/', methods=['GET']) def get_email(backpagepost_id): emails = (Backpageemail.query.filter_by(backpagepostid=backpagepost_id).all()) @@ -127,6 +125,13 @@ def getid_from_mail(email): return jsonify({'backpagepost_ids': [i.backpagepostid for i in ids]}) +# Backpagepost, Backpagephone and Backpagecontent tables joined at this endpoint +@app.route('/api/backpage//title', methods=['GET']) +def get_title_withID(backpagepost_id): + numbers = (Backpagephone.query.filter_by(backpagepostid=backpagepost_id).all()) + + # import pdb; pdb.set_trace() + return jsonify({'numbers': [content.title for n in numbers for content in n.backpagepost.content.all()]}) From 820fe32c3729b4f26622274f715c577c7f330615 Mon Sep 17 00:00:00 2001 From: Kaushik Visvanathan Date: Thu, 22 Jun 2017 21:37:10 -0400 Subject: [PATCH 07/11] Update .gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index ed367e8..e832dc4 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,8 @@ node_modules # Optional REPL history .node_repl_history + +#rest_api folder cache and DS_Store +rest_api/__pycache__ +rest_api/.DS_Store +rest_api/templates/.DS_Store From fce443df63ea62f7081b1a1e7cd126660bd77250 Mon Sep 17 00:00:00 2001 From: Kaushik Visvanathan Date: Thu, 22 Jun 2017 21:37:37 -0400 Subject: [PATCH 08/11] Delete .DS_Store --- rest_api/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 rest_api/.DS_Store diff --git a/rest_api/.DS_Store b/rest_api/.DS_Store deleted file mode 100644 index 40dac61b950eeceaa89f5d9906968ecf370186f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKK~BRk5Zt9b6mjX1qrcD}L{)e}#U0cjI5cV`+I#-RJNOSXy9-KGA2=X{(5__9 z+MczYkz#vAM7QT|BeE8e6$(-5RE*u#p{pP-fogLc Date: Thu, 22 Jun 2017 21:38:03 -0400 Subject: [PATCH 09/11] Delete .DS_Store --- rest_api/templates/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 rest_api/templates/.DS_Store diff --git a/rest_api/templates/.DS_Store b/rest_api/templates/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Thu, 22 Jun 2017 21:39:12 -0400 Subject: [PATCH 10/11] Delete models.cpython-35.pyc --- rest_api/__pycache__/models.cpython-35.pyc | Bin 2592 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 rest_api/__pycache__/models.cpython-35.pyc diff --git a/rest_api/__pycache__/models.cpython-35.pyc b/rest_api/__pycache__/models.cpython-35.pyc deleted file mode 100644 index f91eb55b1ee3054e4d181e80bf34290897fae9ab..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2592 zcmbtV+in|07@oDg-t{SVQBx8XN;#=oBx=MpLJ6r_P=po5E&|`IHl9g5@gCgSb*OV| zo`N^vF%WMtw_N!ZxZ?X~*NM{@!okV@9{=C$%zXdhn+L5{{qX+b4^fq|-`U!yg7F@n z^fwree~X2TMHU-c%zD8~jF;I@aF>~|*m;R9%4}F>FL;G<+W__&PytY7+%bT&2G{^x z#%l(stpQa4b;cV8XsiJafF|QD1GLrv7r++dZ3DE|fEwc+*7xo$L48Y z(0LilQNo3)nb-T7lJS|Ubm_D7(RT-O6 zrKhxc)7r6~SP!jj%lK~;2~pUiiO*qf7YWKEFNVA^7Nxa1$x8?oVy_a4imxJ}j&7|I zDxyG!CQgcuGtdEzG)3v3iewZi)ic3i*pDJh2pcHb>!CAh)AXRPbLb z9l}AOL2qB~Epd2DAjt)Ri!} zoNI^A(T;LtWTEGE?#LL`qWXZ$hqQFF9|d7pXruawT<$X*VSodukIf7v!XT4L44In_ zZBs$oDMWr_vfsyR5Amd=2c%o1THDqm>TAMoq@6l`4^Mgk^RLssy4omRNS%$qSFZz~ zN<`L3mfFSY%7wXGu}p+WvGSKTm2(#;1*a(I9ZQjCGq3M~{7+st8oX9q(}hYq2P*h6 z6l#s<@-ep5&IPU~q^;*Q{z*w(5!TLk`^N`g?;oqrvCPHxPy5op%&VLB(e4-d&HklDn^84&%De8aZT{-J_MdH! B;i&)s From d318505bbccfca7a532ceccb4c7d55971b85ebac Mon Sep 17 00:00:00 2001 From: Kaushik Visvanathan Date: Thu, 22 Jun 2017 21:39:20 -0400 Subject: [PATCH 11/11] Delete restful.cpython-35.pyc --- rest_api/__pycache__/restful.cpython-35.pyc | Bin 6149 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 rest_api/__pycache__/restful.cpython-35.pyc diff --git a/rest_api/__pycache__/restful.cpython-35.pyc b/rest_api/__pycache__/restful.cpython-35.pyc deleted file mode 100644 index ff2295fed073a7f5ab752880b32741f17544e828..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6149 zcmcIoUvm>j67ShvNtP@lgTW5}Wo!r{0rB^8$2lCvHsA|5Bz7u6bve~~cWkY-T8Y^e zU=>`|l~b2{&Bw@Bn%8@}uaKwfp52kOvZzaiAhW~lY)^Mj_pf_;W_D_-aAW3+=RZ#a z{0D}98SLN3CwyZ7xcHBO571&zW6(07W11D+{%3{BDAugVqGp zCZLsvT0S1Nz%RfS(PzM)gxaLyj{PFkin>1qwJG2X_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