mirror of https://github.com/encode/starlette.git
Include import and note in docs
This commit is contained in:
parent
37f8ff0c70
commit
c902f98715
|
@ -7,12 +7,13 @@ what you want to use by default.
|
||||||
```python
|
```python
|
||||||
from starlette.applications import Starlette
|
from starlette.applications import Starlette
|
||||||
from starlette.templating import Jinja2Templates
|
from starlette.templating import Jinja2Templates
|
||||||
|
from starlette.staticfiles import StaticFiles
|
||||||
|
|
||||||
|
|
||||||
templates = Jinja2Templates(directory='templates')
|
templates = Jinja2Templates(directory='templates')
|
||||||
|
|
||||||
app = Starlette(debug=True)
|
app = Starlette(debug=True)
|
||||||
app.mount('/static', StaticFiles(directory='statics'), name='static')
|
app.mount('/static', StaticFiles(directory='static'), name='static')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
|
@ -20,7 +21,7 @@ async def homepage(request):
|
||||||
return templates.TemplateResponse('index.html', {'request': request})
|
return templates.TemplateResponse('index.html', {'request': request})
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that the incoming `request` instance must be included as part of the
|
Note that the [StaticFiles](https://www.starlette.io/staticfiles/) application must be mounted and configured to serve the templates, and the incoming `request` instance must be included as part of the
|
||||||
template context.
|
template context.
|
||||||
|
|
||||||
The Jinja2 template context will automatically include a `url_for` function,
|
The Jinja2 template context will automatically include a `url_for` function,
|
||||||
|
|
Loading…
Reference in New Issue