Skip to content
Snippets Groups Projects
Verified Commit 8f09a8f7 authored by Frank Sauerburger's avatar Frank Sauerburger
Browse files

Add title suggestion app

parent 0bd6feda
No related branches found
No related tags found
No related merge requests found
Pipeline #9633 failed
app.py 0 → 100644
# Copyright 2022, Frank Sauerburger
"""Movie title suggestion api"""
import json
from flask import Flask, request
import qgram
app = Flask(__name__)
with open("examples/titles.json") as fileobj:
titles = json.load(fileobj)
index = qgram.QGramIndex()
for title, _ in titles.values():
index.add_term(title)
@app.route("/")
def suggest():
query = request.args.get("q")
if not query:
return {}
results = index.search(query)
return {
"suggestions": results[:100]
}
flask~=2.1.2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment