-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebAPI.py
More file actions
21 lines (17 loc) · 690 Bytes
/
webAPI.py
File metadata and controls
21 lines (17 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import scraper
from flask import Flask, render_template, request, redirect, session
import logging
app = Flask(__name__)
logging.basicConfig(filename="logpengunjung.log", level=logging.INFO)
@app.route('/tokopedia', methods=['GET'])
def jalanweb():
if request.method == 'GET':
cari = request.args['cari']
hasil = scraper.bukabrowser(cari)
ip = request.environ.get('HTTP_X_REAL_IP', request.remote_addr)
asal = request.headers.get('User-Agent')
ambillog = 'IP Address: '+ip+'\n'+'User Agent: '+asal+'\n'+'Query Search: '+cari
logging.info(ambillog)
return hasil
if __name__ == '__main__':
app.run(host='0.0.0.0', port=2701)