-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
33 lines (28 loc) · 943 Bytes
/
app.py
File metadata and controls
33 lines (28 loc) · 943 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
27
28
29
30
31
32
33
from dis import dis
from operator import truediv
import backend
from flask import Flask, request, jsonify, send_from_directory
from flask_cors import CORS, cross_origin
app = Flask(__name__, static_folder="../webscraper-react-flask/build")
CORS(app)
@app.route("/api/scrape", methods=["POST","GET"], strict_slashes=False)
@cross_origin()
def add_data():
#getting the data as POST
title = request.json['title']
location = request.json['location']
pages = request.json['pages']
country = request.json['country']
distance = request.json['distance']
date = request.json['date']
#processing data
dataObject = backend.Backend(title, location, pages,country, distance, date)
data = dataObject.scrape()
#print(data)
return jsonify(results = data)
@app.route('/')
@cross_origin()
def serve():
return send_from_directory(app.static_folder, 'index.html')
if __name__ == '__main__':
app.run()