Skip to content

Commit da27fa8

Browse files
committed
Moves scrapper to a sole folder
1 parent c33aa51 commit da27fa8

16 files changed

+29
-0
lines changed

.DS_Store

2 KB
Binary file not shown.

app.py

Whitespace-only changes.
File renamed without changes.

scrapper/app.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from pymongo import MongoClient
2+
from flask import Flask, Response, request, jsonify
3+
import simplejson as json
4+
5+
app = Flask(__name__)
6+
7+
client = MongoClient()
8+
db = client.test
9+
10+
def document_result(cursor):
11+
12+
13+
def add_cors_headers(response):
14+
response.headers['Access-Control-Allow-Origin'] = '*'
15+
if request.method == 'OPTIONS':
16+
response.headers['Access-Control-Allow-Methods'] = 'DELETE, GET, POST, PUT'
17+
headers = request.headers.get('Access-Control-Request-Headers')
18+
if headers:
19+
response.headers['Access-Control-Allow-Headers'] = headers
20+
return response
21+
app.after_request(add_cors_headers)
22+
23+
@app.route('/state', methods=['GET'])
24+
def api_state():
25+
data = load_cities_data()
26+
json_data = json.dumps(data)
27+
cursor = db.test_cities.find( {"$and": [ { "city": city_name}, { "name": indicator_name } ] } )
28+
29+
return Response(jsonify(json_fixed), mimetype='application/json')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

fill_db.py scrapper/fill_db.py

File renamed without changes.
File renamed without changes.

scrapy.cfg scrapper/scrapy.cfg

File renamed without changes.

0 commit comments

Comments
 (0)