Skip to content

Commit a31e816

Browse files
committed
Starter code for chapter 5, view models.
1 parent 513a7b7 commit a31e816

26 files changed

+639
-0
lines changed

code/ch5-viewmodels/.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/ch5-viewmodels/.idea/ch5-viewmodels.iml

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/ch5-viewmodels/.idea/inspectionProfiles/profiles_settings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/ch5-viewmodels/.idea/misc.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/ch5-viewmodels/.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/ch5-viewmodels/.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code/ch5-viewmodels/main.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import fastapi
2+
import fastapi_chameleon
3+
import uvicorn
4+
from starlette.staticfiles import StaticFiles
5+
6+
from views import account
7+
from views import home
8+
from views import packages
9+
10+
app = fastapi.FastAPI()
11+
12+
13+
def main():
14+
configure(dev_mode=True)
15+
uvicorn.run(app, host='127.0.0.1', port=8000, debug=True)
16+
17+
18+
def configure(dev_mode: bool):
19+
configure_templates(dev_mode)
20+
configure_routes()
21+
22+
23+
def configure_templates(dev_mode: bool):
24+
fastapi_chameleon.global_init('templates', auto_reload=dev_mode)
25+
26+
27+
def configure_routes():
28+
app.mount('/static', StaticFiles(directory='static'), name='static')
29+
app.include_router(home.router)
30+
app.include_router(account.router)
31+
app.include_router(packages.router)
32+
33+
34+
if __name__ == '__main__':
35+
main()
36+
else:
37+
configure(dev_mode=False)

code/ch5-viewmodels/placeholder.txt

Whitespace-only changes.

code/ch5-viewmodels/requirements.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fastapi
2+
uvicorn
3+
aiofiles
4+
5+
git+https://github.com/mikeckennedy/fastapi-chameleon
6+
7+
starlette
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
.form-container {
3+
padding: 50px;
4+
}
5+
6+
form.account-form > * {
7+
margin-top: 5px;
8+
margin-bottom: 5px;
9+
}
10+
11+
form.account-form h1 {
12+
text-align: center;
13+
}
14+
form.account-form button {
15+
float: right;
16+
}
17+
18+
form.account-form {
19+
margin-left: auto;
20+
margin-right: auto;
21+
max-width: 450px;
22+
background-color: #c9c9c9;
23+
border: 1px solid gray;
24+
border-radius: 5px;
25+
padding: 10px;
26+
}
27+
28+
.error-msg {
29+
text-align: center;
30+
}
+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
.navbar {
3+
border-radius: 0px;
4+
padding-bottom: 10px;
5+
}
6+
7+
.navbar-inverse .navbar-collapse, .navbar-inverse .navbar-form {
8+
border-color: #02377c;
9+
10+
color: white;
11+
}
12+
13+
.navbar-inverse {
14+
background-color: #0066aa;
15+
border-color: #0067a3;
16+
}
17+
18+
.navbar-inverse .navbar-nav > .active > a, .navbar-inverse .navbar-nav > .active > a:hover, .navbar-inverse .navbar-nav > .active > a:focus {
19+
color: #fff;
20+
background-color: #024bbf;
21+
}
22+
23+
.navbar-inverse .navbar-brand,
24+
.navbar-inverse .navbar-nav > li > a {
25+
color: #fff;
26+
}
27+
28+
.navbar-inverse .navbar-brand:hover {
29+
text-decoration: underline;
30+
}
31+
32+
.navbar-inverse .navbar-toggle {
33+
border-color: #eee;
34+
}
35+
36+
.navbar {
37+
margin-bottom: 0px;
38+
}
39+
40+
41+
.navbar-brand img {
42+
width: 65px;
43+
margin-left: 60px;
44+
}
45+
46+
.navbar-inverse .navbar-toggle {
47+
margin-top: 20px;
48+
}
49+
50+
.navbar-nav li {
51+
margin-top: 20px;
52+
}
53+
54+
#last_nav_link {
55+
margin-right: 45px;
56+
}
57+
58+
nav {
59+
padding: 10px;
60+
font-size: 17px;
61+
color: white;
62+
height: 85px;
63+
background-color: #0073b7;
64+
}
65+
66+
nav > a {
67+
color: white;
68+
margin-right: 10px;
69+
}
70+
71+
.nav-expand-line {
72+
height: 2px;
73+
margin: 6px;
74+
background-color: white;
75+
}
76+
77+
#navbarSupportedContent {
78+
background-color: #0066aa;
79+
padding: 10px;
80+
}
+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
.details .pypi-stats {
2+
text-align: left;
3+
color: #555;
4+
}
5+
6+
.details.content .hero,
7+
.details.content .sub-hero,
8+
.details.content .hero h1 {
9+
text-align: left;
10+
}
11+
12+
.content .sub-hero {
13+
font-family: Consolas, "andale mono", "lucida console", monospace;
14+
padding: 10px;
15+
background-color: #255c8f;
16+
border: 1px dotted gray;
17+
font-size: 20px;
18+
font-weight: 300;
19+
display: inline-block;
20+
}
21+
22+
23+
.active-release {
24+
margin-top: 20px;
25+
text-align: right;
26+
}
27+
28+
.go-latest-button, .go-older-button {
29+
padding: 10px;
30+
border: 1px dotted gray;
31+
font-size: 16px;
32+
font-weight: 300;
33+
display: inline-block;
34+
}
35+
36+
.go-latest-button {
37+
background-color: #3a7d32;
38+
}
39+
40+
.go-older-button {
41+
background-color: #c63e45;
42+
}
43+
44+
.latest-release-date {
45+
margin-top: 10px;
46+
font-size: 14px;
47+
font-weight: normal;
48+
font-style: italic;
49+
}
50+
51+
.content.details .hero h1 {
52+
max-width: none;
53+
margin-left: 0px;
54+
padding-left: 0px;
55+
text-align: left;
56+
}
57+
58+
h3 {
59+
font-size: 14px;
60+
font-weight: bold;
61+
}
62+
63+
.nav-sidebar-section {
64+
padding-top: 15px;
65+
}
66+
67+
68+
.nav-sidebar-section a {
69+
display: block;
70+
padding: 10px;
71+
font-size: 15px;
72+
color: #2b6ca8;
73+
}
74+
75+
.nav-sidebar-section a.link-inline {
76+
display: inline-block;
77+
padding: 0px;
78+
}
79+
80+
.nav-sidebar-section .meta-topic {
81+
padding: 5px;
82+
}
83+
84+
.nav-sidebar-section .meta-topic span {
85+
font-weight: bold;
86+
}
87+
88+
.maintainer img {
89+
width: 50px;
90+
}
91+
92+
.maintainer a {
93+
display: inline-block;
94+
}
95+
96+
.release-entry {
97+
border: 1px dotted gray;
98+
margin: 10px;
99+
padding: 10px;
100+
font-size: 16px;
101+
}
102+
103+
.release-entry a {
104+
font-size: 20px;
105+
}
106+
107+
.release-entry img {
108+
padding-right: 10px;
109+
}
110+
111+
.release-entry .when {
112+
margin-left: 50px;
113+
}
114+
115+
pre {
116+
font-size: .7em;
117+
}

0 commit comments

Comments
 (0)