renamed 22-async/

This commit is contained in:
Luciano Ramalho
2021-03-11 16:11:39 -03:00
parent 7c88948b22
commit e1cd63aa04
15 changed files with 8 additions and 8 deletions

View File

@@ -0,0 +1,37 @@
#!/usr/bin/env python3
import json
import unicodedata
from bottle import route, request, run, static_file
from charindex import InvertedIndex
index = {}
@route('/')
def form():
return static_file('form.html', root = 'static/')
@route('/search')
def search():
query = request.query['q']
chars = index.search(query)
results = []
for char in chars:
name = unicodedata.name(char)
results.append({'char': char, 'name': name})
return json.dumps(results).encode('UTF-8')
def main(port):
global index
index = InvertedIndex()
host = 'localhost'
run(host='localhost', port=port, debug=True)
if __name__ == '__main__':
main(8000)