dx2102 commited on
Commit
0a3000e
1 Parent(s): 3e53e47

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +2 -2
server.py CHANGED
@@ -29,7 +29,7 @@ class Decl:
29
  def parse_exported_file():
30
  decls = []
31
  print('Reading exported.txt')
32
- lines = open('exported.txt', 'r').read() # 1000000)
33
  print('Splitting exported.txt')
34
  lines = lines.split('----ast----\n')[1:]
35
  print('Parsing exported.txt')
@@ -47,6 +47,6 @@ decls = parse_exported_file()
47
  @app.get("/search")
48
  async def search(query: str = Query(...)):
49
  matched = [decl for decl in decls if query in decl.name]
50
- matched = sorted(matched, key=lambda decl: decl.name)
51
  matched_results = [asdict(decl) for decl in matched]
52
  return JSONResponse(content=matched_results)
 
29
  def parse_exported_file():
30
  decls = []
31
  print('Reading exported.txt')
32
+ lines = open('exported.txt', 'r').read(1000000)
33
  print('Splitting exported.txt')
34
  lines = lines.split('----ast----\n')[1:]
35
  print('Parsing exported.txt')
 
47
  @app.get("/search")
48
  async def search(query: str = Query(...)):
49
  matched = [decl for decl in decls if query in decl.name]
50
+ matched = sorted(matched, key=lambda decl: decl.name)[:10]
51
  matched_results = [asdict(decl) for decl in matched]
52
  return JSONResponse(content=matched_results)