-
Notifications
You must be signed in to change notification settings - Fork 0
/
webserver.py
40 lines (31 loc) · 1.07 KB
/
webserver.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
30
31
32
33
34
35
36
37
38
39
40
import asyncio
from flask import Flask, Response, render_template, request, jsonify, send_file
from flask_cors import CORS
from blackbird import findUsername
import logging
import requests
app = Flask(__name__, static_folder='templates/static')
app.config['CORS_HEADERS'] = 'Content-Type'
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
CORS(app, resources={r"/*": {"origins": "*"}})
loop = asyncio.get_event_loop()
logging.getLogger('werkzeug').disabled = True
@app.route('/')
def home():
return render_template('index.html')
@app.route('/search/username', methods=["POST"])
def searchUsername():
content = request.get_json()
username = content['username']
interfaceType = 'web'
results = loop.run_until_complete(findUsername(username, interfaceType))
return jsonify(results)
@app.route('/image', methods=["GET"])
def getImage():
url = request.args.get('url')
try:
imageBinary = requests.get(url).content
return Response(imageBinary, mimetype='image/gif')
except:
return Response(status=500)
app.run(host='0.0.0.0', port=9797)