Skip to content

Commit 044db8d

Browse files
committed
update fasatapi post
1 parent 89fe45c commit 044db8d

File tree

7 files changed

+26
-16
lines changed

7 files changed

+26
-16
lines changed

content/posts/how-fastapi-works.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ title = 'How FastAPI Works'
55
+++
66
FastAPI 的工作原理: 从 routing 到 lifecycle 以及在现实中的使用
77

8-
### Fastapi
9-
Fastapi 是一个现代的 Python Web 框架, 注重**高性能****开发者效率**. 旨在帮助开发者编写结构清晰、可靠的API, 同时尽量减少样板代码 (boilerplate)
8+
### FastAPI
9+
FastAPI 是一个现代的 Python Web 框架, 注重**高性能****开发者效率**. 旨在帮助开发者编写结构清晰、可靠的API, 同时尽量减少样板代码 (boilerplate)
1010

1111
其由以下两个库驱动:
1212
- **Starlette**: 负责 Web 服务器逻辑、路由、中间件和异步能力
@@ -49,6 +49,11 @@ FastAPI App
4949
1. 在应用对象上定义
5050
适合小项目或原型验证
5151
```python
52+
from fastapi import FastAPI
53+
54+
app = FastAPI()
55+
56+
@app.get("/items/{item_id}")
5257
def read_item():
5358
return {"item_id": item_id}
5459
```

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<span class="text-sm font-medium">GitHub</span>
5050
</a><a href=mailto:[email protected] target=_blank rel="noopener noreferrer" class="bg-muted text-muted-foreground hover:text-primary hover:bg-primary/10 focus:ring-primary/20 inline-flex items-center gap-2 rounded-lg px-3 py-2 transition-all duration-300 ease-out hover:-translate-y-0.5 hover:scale-105 focus:ring-2 focus:outline-none" title=Email><svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-label="Email"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22.0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5A2 2 0 003 7v10a2 2 0 002 2z"/></svg>
5151
<span class="text-sm font-medium">Email</span></a></div></div></div></div></section><section class=post-list><div class="mb-6 flex items-center justify-between"><h2 class="text-foreground text-2xl font-bold">Recent Posts</h2></div><div class=space-y-4><article class=group><a href=/posts/how-fastapi-works/ class=block><div class="bg-card border-border hover:bg-primary/5 hover:border-primary/20 focus:ring-primary/20 relative flex flex-col overflow-hidden rounded-xl border transition-all duration-300 ease-out hover:-translate-y-1 hover:scale-[1.02] hover:shadow-lg focus:ring-2 focus:outline-none min-h-[200px]"><div class="block md:hidden"><div class="aspect-[2/1] overflow-hidden"><div class="from-orange-500/20 to-red-500/10 relative aspect-[2/1] overflow-hidden bg-gradient-to-br" style="background-blend-mode:overlay;background-color:color-mix(in srgb,var(--color-primary) 15%,transparent)"><div class="absolute inset-0"><div class="absolute left-[20%] top-[20%] h-5 w-5 rotate-45 border-2 border-white/80 bg-white/15"></div><div class="absolute right-[25%] top-[25%] h-4 w-4 rotate-12 border border-white/70 bg-white/12"></div><div class="absolute left-[30%] bottom-[30%] h-3 w-3 rotate-60 border border-white/60 bg-white/10"></div><div class="absolute right-[20%] bottom-[20%] h-4 w-4 rotate-30 border border-white/65 bg-white/13"></div><div class="absolute left-[45%] top-[45%] h-2 w-2 rotate-45 border border-white/50 bg-white/8"></div><div class="absolute left-[15%] top-[40%] h-0.5 w-8 rotate-45 bg-white/40"></div><div class="absolute right-[15%] top-[35%] h-0.5 w-6 rotate-12 bg-white/35"></div><div class="absolute left-[40%] bottom-[15%] h-0.5 w-5 -rotate-30 bg-white/30"></div><div class="absolute top-[35%] right-[40%] h-2 w-2 rounded-full bg-white/35"></div><div class="absolute bottom-[40%] left-[35%] h-1.5 w-1.5 rounded-full bg-white/30"></div><div class="absolute top-[50%] left-[50%] h-1 w-1 rounded-full bg-white/25"></div></div></div></div></div><div class="absolute top-0 right-0 hidden h-full w-80 transition-opacity duration-300 group-hover:opacity-90 md:block"><div class="h-full w-full"><div class="from-orange-500/20 to-red-500/10 relative h-full w-full overflow-hidden bg-gradient-to-br" style="background-blend-mode:overlay;background-color:color-mix(in srgb,var(--color-primary) 15%,transparent)"><div class="absolute inset-0"><div class="absolute left-[20%] top-[20%] h-5 w-5 rotate-45 border-2 border-white/80 bg-white/15"></div><div class="absolute right-[25%] top-[25%] h-4 w-4 rotate-12 border border-white/70 bg-white/12"></div><div class="absolute left-[30%] bottom-[30%] h-3 w-3 rotate-60 border border-white/60 bg-white/10"></div><div class="absolute right-[20%] bottom-[20%] h-4 w-4 rotate-30 border border-white/65 bg-white/13"></div><div class="absolute left-[45%] top-[45%] h-2 w-2 rotate-45 border border-white/50 bg-white/8"></div><div class="absolute left-[15%] top-[40%] h-0.5 w-8 rotate-45 bg-white/40"></div><div class="absolute right-[15%] top-[35%] h-0.5 w-6 rotate-12 bg-white/35"></div><div class="absolute left-[40%] bottom-[15%] h-0.5 w-5 -rotate-30 bg-white/30"></div><div class="absolute top-[35%] right-[40%] h-2 w-2 rounded-full bg-white/35"></div><div class="absolute bottom-[40%] left-[35%] h-1.5 w-1.5 rounded-full bg-white/30"></div><div class="absolute top-[50%] left-[50%] h-1 w-1 rounded-full bg-white/25"></div></div></div></div></div><div class="absolute top-0 right-0 hidden h-full w-80 opacity-0 transition-opacity duration-300 group-hover:opacity-100 md:block bg-gradient-to-l from-primary/5"></div><div class="relative z-10 flex flex-1 flex-col p-6 md:pr-[21rem]"><h3 class="text-foreground group-hover:text-primary mb-4 text-lg font-semibold leading-tight transition-colors duration-200">How FastAPI Works</h3><p class="text-muted-foreground mb-4 text-sm leading-relaxed line-clamp-2">FastAPI 的工作原理: 从 routing 到 lifecycle 以及在现实中的使用
52-
Fastapi Fastapi 是一个现代的 Python Web 框架, 注重高性能和开发者效率. 旨在帮助开发者编写结构清晰、可靠的API, 同时尽量减少样板代码 (boilerplate)</p><div class="mt-auto text-sm text-muted-foreground"><div class="flex items-center gap-3"><div class="flex items-center gap-1.5"><svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-label="Published on"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5A2 2 0 003 7v12a2 2 0 002 2z"/></svg>
52+
FastAPI FastAPI 是一个现代的 Python Web 框架, 注重高性能和开发者效率. 旨在帮助开发者编写结构清晰、可靠的API, 同时尽量减少样板代码 (boilerplate)</p><div class="mt-auto text-sm text-muted-foreground"><div class="flex items-center gap-3"><div class="flex items-center gap-1.5"><svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-label="Published on"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5A2 2 0 003 7v12a2 2 0 002 2z"/></svg>
5353
<time datetime=2025-08-04 class=font-medium>August 04, 2025</time></div><div class="flex items-center gap-1.5"><svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-label="Reading time"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3A9 9 0 113 12a9 9 0 0118 0z"/></svg>
5454
<span class=font-medium>3 minute</span></div></div></div></div></div></a></article><article class=group><a href=/posts/executing-arbitrary-python-code-from-a-comment/ class=block><div class="bg-card border-border hover:bg-primary/5 hover:border-primary/20 focus:ring-primary/20 relative flex flex-col overflow-hidden rounded-xl border transition-all duration-300 ease-out hover:-translate-y-1 hover:scale-[1.02] hover:shadow-lg focus:ring-2 focus:outline-none min-h-[200px]"><div class="block md:hidden"><div class="aspect-[2/1] overflow-hidden"><div class="from-indigo-500/20 to-purple-500/10 relative aspect-[2/1] overflow-hidden bg-gradient-to-br" style="background-blend-mode:overlay;background-color:color-mix(in srgb,var(--color-primary) 15%,transparent)"><div class="absolute inset-0"><div class="absolute left-[20%] top-[20%] h-5 w-5 rotate-45 border-2 border-white/80 bg-white/15"></div><div class="absolute right-[25%] top-[25%] h-4 w-4 rotate-12 border border-white/70 bg-white/12"></div><div class="absolute left-[30%] bottom-[30%] h-3 w-3 rotate-60 border border-white/60 bg-white/10"></div><div class="absolute right-[20%] bottom-[20%] h-4 w-4 rotate-30 border border-white/65 bg-white/13"></div><div class="absolute left-[45%] top-[45%] h-2 w-2 rotate-45 border border-white/50 bg-white/8"></div><div class="absolute left-[15%] top-[40%] h-0.5 w-8 rotate-45 bg-white/40"></div><div class="absolute right-[15%] top-[35%] h-0.5 w-6 rotate-12 bg-white/35"></div><div class="absolute left-[40%] bottom-[15%] h-0.5 w-5 -rotate-30 bg-white/30"></div><div class="absolute top-[35%] right-[40%] h-2 w-2 rounded-full bg-white/35"></div><div class="absolute bottom-[40%] left-[35%] h-1.5 w-1.5 rounded-full bg-white/30"></div><div class="absolute top-[50%] left-[50%] h-1 w-1 rounded-full bg-white/25"></div></div></div></div></div><div class="absolute top-0 right-0 hidden h-full w-80 transition-opacity duration-300 group-hover:opacity-90 md:block"><div class="h-full w-full"><div class="from-indigo-500/20 to-purple-500/10 relative h-full w-full overflow-hidden bg-gradient-to-br" style="background-blend-mode:overlay;background-color:color-mix(in srgb,var(--color-primary) 15%,transparent)"><div class="absolute inset-0"><div class="absolute left-[20%] top-[20%] h-5 w-5 rotate-45 border-2 border-white/80 bg-white/15"></div><div class="absolute right-[25%] top-[25%] h-4 w-4 rotate-12 border border-white/70 bg-white/12"></div><div class="absolute left-[30%] bottom-[30%] h-3 w-3 rotate-60 border border-white/60 bg-white/10"></div><div class="absolute right-[20%] bottom-[20%] h-4 w-4 rotate-30 border border-white/65 bg-white/13"></div><div class="absolute left-[45%] top-[45%] h-2 w-2 rotate-45 border border-white/50 bg-white/8"></div><div class="absolute left-[15%] top-[40%] h-0.5 w-8 rotate-45 bg-white/40"></div><div class="absolute right-[15%] top-[35%] h-0.5 w-6 rotate-12 bg-white/35"></div><div class="absolute left-[40%] bottom-[15%] h-0.5 w-5 -rotate-30 bg-white/30"></div><div class="absolute top-[35%] right-[40%] h-2 w-2 rounded-full bg-white/35"></div><div class="absolute bottom-[40%] left-[35%] h-1.5 w-1.5 rounded-full bg-white/30"></div><div class="absolute top-[50%] left-[50%] h-1 w-1 rounded-full bg-white/25"></div></div></div></div></div><div class="absolute top-0 right-0 hidden h-full w-80 opacity-0 transition-opacity duration-300 group-hover:opacity-100 md:block bg-gradient-to-l from-primary/5"></div><div class="relative z-10 flex flex-1 flex-col p-6 md:pr-[21rem]"><h3 class="text-foreground group-hover:text-primary mb-4 text-lg font-semibold leading-tight transition-colors duration-200">Executing arbitrary Python code from a comment</h3><p class="text-muted-foreground mb-4 text-sm leading-relaxed line-clamp-2">通过注释执行任意Python代码
5555
问题描述 Q: 只能控制一行的.py代码中注释的内容(\n\r均会被替换为空字符), 如何执行任意代码?

0 commit comments

Comments
 (0)