-
Notifications
You must be signed in to change notification settings - Fork 7
/
kleinapp.py
42 lines (25 loc) · 813 Bytes
/
kleinapp.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
""" This module is a Klein web app for returning company embeddings"""
from klein import Klein
from app.pipelines import Pipeline
from app.urls import URLFinder
app = Klein()
@app.route("/")
def home(request):
"""
A welcome function used for testing
:return: string
"""
return "Welcome to the Company2Vec API!"
@app.route("/company/<company_name>", methods=['GET'])
def create_embedding(request, company_name):
"""
Finds the URL, scrapes the website, returns the embedding
:param company_name: company name
:type company_name: str
:return: company embedding dictionary
"""
url = URLFinder().run(company=company_name)
result = Pipeline(overwrite=False).run(url=url)
return result
if __name__ == '__main__':
app.run('0.0.0.0', port=5000)