-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
27 lines (20 loc) · 713 Bytes
/
app.py
File metadata and controls
27 lines (20 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from flask import Flask, jsonify, abort, make_response
import os
import scraping
from flask_cors import *
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/Users/200ok/www/service-account-file.json"
app = Flask(__name__)
CORS(app, supports_credentials = True)
@app.route('/comments/<id>', methods=['GET'])
def get_comments(id):
data = scraping.comments(id)
return jsonify({ 'data': data })
@app.route('/searchResIds/<q>', methods=['GET'])
def get_searchResIds(q):
res = scraping.getSearchResIds(q)
return jsonify({ 'data': res })
@app.errorhandler(404)
def not_found(error):
return make_response(jsonify({'error': 'Not found'}), 404)
if __name__ == '__main__':
app.run(debug = True)