Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ef389ad

Browse files
Now with static file support.
1 parent 6a5a00d commit ef389ad

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

‎code/ch4-templates/.idea/webResources.xml‎

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎code/ch4-templates/main.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fastapi
22
import fastapi_chameleon
33
import uvicorn
4+
from starlette.staticfiles import StaticFiles
45

56
from views import account
67
from views import home
@@ -24,6 +25,7 @@ def configure_templates():
2425

2526

2627
def configure_routes():
28+
app.mount('/static', StaticFiles(directory='static'), name='static')
2729
app.include_router(home.router)
2830
app.include_router(account.router)
2931
app.include_router(packages.router)

‎code/ch4-templates/requirements.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
fastapi
22
uvicorn
3+
aiofiles
34

45
git+https://github.com/mikeckennedy/fastapi-chameleon

‎code/ch4-templates/static/site.css‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
background: #cfd4ff;
3+
}

‎code/ch4-templates/templates/shared/_layout.pt‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>PyPI</title>
6-
<style>
7-
body {
8-
background: #cfffcf;
9-
}
10-
</style>
6+
<link rel="stylesheet" href="/static/site.css">
117
</head>
128
<body>
139

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /