Ingredient parsing
This commit is contained in:
parent
3baa096360
commit
17f59fdaac
1 changed files with 11 additions and 4 deletions
15
main.py
15
main.py
|
|
@ -1,8 +1,9 @@
|
||||||
|
import sqlite3
|
||||||
|
import product, db, recipe
|
||||||
|
|
||||||
|
from typing import List
|
||||||
from fastapi import FastAPI, Depends, HTTPException
|
from fastapi import FastAPI, Depends, HTTPException
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
import sqlite3
|
|
||||||
from recipe import parse_recipe
|
|
||||||
import product, db
|
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
@ -25,7 +26,13 @@ async def get_db():
|
||||||
|
|
||||||
@app.get("/recipes/parse")
|
@app.get("/recipes/parse")
|
||||||
async def parse_recipe_handler(url: str, conn: sqlite3.Connection = Depends(get_db)):
|
async def parse_recipe_handler(url: str, conn: sqlite3.Connection = Depends(get_db)):
|
||||||
return await parse_recipe(conn, url)
|
return await recipe.parse_recipe(conn, url)
|
||||||
|
|
||||||
|
@app.get("/recipes/ingredients/parse")
|
||||||
|
async def parse_ingredients(lines: List[str], conn: sqlite3.Connection = Depends(get_db)):
|
||||||
|
ingredients = recipe.parse_ingredient_from_nlp(lines)
|
||||||
|
recipe.match_existing_products(conn, ingredients)
|
||||||
|
return ingredients
|
||||||
|
|
||||||
@app.post("/product/")
|
@app.post("/product/")
|
||||||
async def create_product(url: str, conn: sqlite3.Connection = Depends(get_db)):
|
async def create_product(url: str, conn: sqlite3.Connection = Depends(get_db)):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue