Spaces:
Sleeping
Sleeping
Update server.py
Browse files
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(
|
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)
|