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 d0f67bf

Browse files
# Conflicts: # .gitignore # .idea/100web-course.iml
2 parents d9680c7 + e1699f6 commit d0f67bf

File tree

12 files changed

+223
-21
lines changed

12 files changed

+223
-21
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,4 @@ days/013-016-css-basics/demos/selectorville/.idea/selectorville.iml
174174
days/041-044-react/**node_modules
175175
.idea/100web-course.iml
176176
.idea/ruff.xml
177+
ruff.xml

‎.idea/100web-course.iml‎

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

‎.idea/ruff.xml‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from program import app
1+
from program import app# noqa: F401
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from flask import Flask
2+
from program import routes # noqa: F401
23

34
app = Flask(__name__)
45

5-
fromprogramimportroutes
6+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
click
2+
Flask
3+
itsdangerous
4+
Jinja2
5+
MarkupSafe
6+
python-dotenv
7+
werkzeug
Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
1-
click==6.7
2-
Flask==1.0.2
3-
itsdangerous==0.24
4-
Jinja2>=2.10.1
5-
MarkupSafe==1.0
6-
python-dotenv==0.9.1
7-
werkzeug>=0.15.3
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.11
3+
# by the following command:
4+
#
5+
# pip-compile requirements.piptools
6+
#
7+
blinker==1.7.0
8+
# via flask
9+
click==8.1.7
10+
# via
11+
# -r requirements.piptools
12+
# flask
13+
flask==3.0.0
14+
# via -r requirements.piptools
15+
itsdangerous==2.1.2
16+
# via
17+
# -r requirements.piptools
18+
# flask
19+
jinja2==3.1.2
20+
# via
21+
# -r requirements.piptools
22+
# flask
23+
markupsafe==2.1.3
24+
# via
25+
# -r requirements.piptools
26+
# jinja2
27+
# werkzeug
28+
python-dotenv==1.0.0
29+
# via -r requirements.piptools
30+
werkzeug==3.0.1
31+
# via
32+
# -r requirements.piptools
33+
# flask

‎days/005-008-html5/demos/yahoo_clone/.idea/dictionaries/mkennedy.xml‎

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎days/005-008-html5/demos/yahoo_clone/.idea/encodings.xml‎

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from typing import Optional
2+
3+
import fastapi
4+
import uvicorn
5+
6+
api = fastapi.FastAPI()
7+
8+
9+
@api.get('/')
10+
def index():
11+
body = "<html>" \
12+
"<body style='padding: 10px;'>" \
13+
"<h1>Welcome to the API</h1>" \
14+
"<div>" \
15+
"Try it: <a href='/api/calculate?x=7&y=11'>/api/calculate?x=7&y=11</a>" \
16+
"</div>" \
17+
"</body>" \
18+
"</html>"
19+
20+
return fastapi.responses.HTMLResponse(content=body)
21+
22+
23+
@api.get('/api/calculate')
24+
def calculate(x: int, y: int, z: Optional[int] = None):
25+
if z == 0:
26+
return fastapi.responses.JSONResponse(
27+
content={"error": "ERROR: Z cannot be zero."},
28+
status_code=400)
29+
30+
value = x + y
31+
32+
if z is not None:
33+
value /= z
34+
35+
return {
36+
'x': x,
37+
'y': y,
38+
'z': z,
39+
'value': value
40+
}
41+
42+
43+
# uvicorn was updated, and it's type definitions don't match FastAPI,
44+
# but the server and code still work fine. So ignore PyCharm's warning:
45+
# noinspection PyTypeChecker
46+
uvicorn.run(api, port=8000, host="127.0.0.1")

0 commit comments

Comments
(0)

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