ch22: new README.md and minor edits

This commit is contained in:
Luciano Ramalho
2021-04-24 20:49:53 -03:00
parent eee989cbd6
commit 063a540868
5 changed files with 51 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
import pathlib
from pathlib import Path
from unicodedata import name
from fastapi import FastAPI
@@ -18,9 +18,8 @@ class CharName(BaseModel): # <2>
def init(app): # <3>
app.state.index = InvertedIndex()
static = pathlib.Path(__file__).parent.absolute() / 'static' # <4>
with open(static / 'form.html') as fp:
app.state.form = fp.read()
static = Path(__file__).parent.absolute() / 'static' # <4>
app.state.form = (static / 'form.html').read_text()
init(app) # <5>
@@ -33,4 +32,4 @@ async def search(q: str): # <7>
def form(): # <9>
return app.state.form
# no main funcion # <10>
# no main funcion # <10>