-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb.py
29 lines (27 loc) · 1.13 KB
/
web.py
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
import ambildata
from flask import Flask, render_template, request, redirect, session
import logging
app = Flask(__name__)
logging.basicConfig(filename="logpengunjung.log", level=logging.INFO)
@app.route('/opendatakpu/dalamnegeri', methods=['GET'])
def jalanweb():
if request.method == 'GET':
cari = request.args['kota']
hasil = ambildata.dalamnegeri(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
@app.route('/opendatakpu/profilpartai', methods=['GET'])
def jalanweb2():
if request.method == 'GET':
cari = request.args['partai']
hasil = ambildata.profilpartai(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=6969)