forked from antoniaci/blackbird
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebserver.py
More file actions
28 lines (22 loc) · 780 Bytes
/
Copy pathwebserver.py
File metadata and controls
28 lines (22 loc) · 780 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
import asyncio
from flask import Flask, render_template, request, jsonify
from flask_cors import CORS
from blackbird import findUsername
import logging
import os
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']
results = loop.run_until_complete(findUsername(username))
return jsonify(results)
app.run('0.0.0.0')