Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
FastAPI+VercelでZennのバッジをお手軽に作る
Search
ganyariya
January 20, 2021
Technology
910
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
FastAPI+VercelでZennのバッジをお手軽に作る
https://rakus.connpass.com/event/198587/
ganyariya
January 20, 2021
More Decks by ganyariya
See All by ganyariya
The Hundred Machine Learning 7.4-7.7
ganariya
0
71
ありがとう競技プログラミングこんにちはDocker
ganariya
0
1.7k
輪講 The hundred ML3.3-3.5
ganariya
0
110
Other Decks in Technology
See All in Technology
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
15
110k
関数型の考えを TypeScript に持ち込んで、テストしやすい純粋関数を増やす / Pure at the Core, Effects at the Edge: Bringing Functional Thinking into TypeScript
kaminashi
1
130
10年目を迎えた「ABEMA」がどのように AI 活用を推進して、AI 駆動開発にシフトしているのか / How ABEMA, entering its 10th year, is promoting the use of AI and shifting toward AI-driven development
miyukki
0
160
Claude Codeとハーネスについて考えてみる
oikon48
19
9.5k
インフラと開発の垣根を超えていき!〜元AWSインフラエンジニアがAWS開発で奮闘している話〜
hatahata021
3
260
kintone の AI コワーカーを、 Anthropic にエージェントを"ホストさせて"作った話 #devkinmeetup
sugimomoto
0
110
AIと共生する開発者プラットフォーム:バクラクのモノレポ×マイクロサービス基盤
sakajunquality
2
3.6k
DatabricksにおけるMCPソリューション
taka_aki
1
260
オブザーバビリティ、本当に活用できてる? 〜API連携×生成AIで成熟度を自動評価〜
dmmsre
1
3.3k
個人開発で育てる「大規模設計の苗床」 - AI時代の1人開発から始める業務への知識接続 / The Seedbed for Large-Scale Design - From AI-Era Solo Projects to Professional Knowledge
bitkey
PRO
1
270
凡エンジニアがこの先生きのこるためには。〜TypeScript完全に理解したい〜
alchemy1115
2
270
“それは自分の仕事じゃない"を越えて行け
yuukiyo
1
400
Featured
See All Featured
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Agile that works and the tools we love
rasmusluckow
331
22k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
300
Writing Fast Ruby
sferik
630
63k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Ruling the World: When Life Gets Gamed
codingconduct
0
280
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
Marketing to machines
jonoalderson
1
5.6k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
900
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
340
Transcript
FastAPI+VercelでZennのバッジをお⼿軽に作る ganariya FastAPI+Vercel -> Zenn-Badge ganariya
ganariyaの⾃⼰紹介 普段は競技プログラミングをしています そのためバックエンドやAPIは初⼼者です 温かい⽬で⾒守ってやってください 履歴書はGitHubのGanariyaリポジトリにあります ⻑期インターンが終わり、アルバイトを探しています (もしよければぜひ...)(ぜひ...) FastAPI+Vercel -> Zenn-Badge
ganariya
デモ FastAPI+Vercel -> Zenn-Badge ganariya
FastAPI+Vercel -> Zenn-Badge ganariya
FastAPI+Vercel -> Zenn-Badge ganariya
FastAPI+Vercel -> Zenn-Badge ganariya
FastAPIのご紹介 FastAPI+Vercel -> Zenn-Badge ganariya
FastAPI is 何 Python製REST Framework 似たものだと Flask 2018年にできており⾮常にモダンで⾼機能 (Python3.6〜) ASGI
⾮同期処理 GraphQL / WebSocket FastAPIのうれしさ3選について紹介 FastAPI+Vercel -> Zenn-Badge ganariya
その1 型ヒントとバリデーション Type Hintsを積極的に利⽤したフレームワーク username:str と引数で指定すると ⾃動で引数の型をバリデーション 型が正しいかなどの確認ロジックをコードで書かなくてよい 返り値なども型の指定が可能 型
-> IDEの恩恵を受けられる @app.get("/{username}/liked", response_class=HTMLResponse) def get_liked(username: str): user: User = scrape_user(username) badge = make_badge(username, 'Zenn liked', str(user.total_liked_count)) return HTMLResponse(content=badge, status_code=200, media_type='image/svg+xml') FastAPI+Vercel -> Zenn-Badge ganariya
その2 OpenAPIとSwagger-UI FastAPIは⾃動でOpenAPIのフォーマットを吐き出す /docs にアクセスするとSwagger-UIが⾃動で作成される 型をPythonで書くとそのままSwaggerへ! FastAPI+Vercel -> Zenn-Badge ganariya
その3 ドキュメント ドキュメントがとても丁寧 TutorialからAdvancedまで体系的に書かれている ファイル分割 , モジュールのプラクティス なども触れられている FastAPI+Vercel ->
Zenn-Badge ganariya
Vercel FastAPI+Vercel -> Zenn-Badge ganariya
Vercel もともとNow(Zeit社)というサービス そのため、ネットの記事の情報がかなり混在している 似たサービスだと Heroku GitHubから⾃動デプロイ 無料枠が⼤きい 無制限のWebサイト+API Go, Python,
Node.jsなどのサーバーレス ただしデプロイ回数は1⽇あたり制限あり DBが使えない (サーバーレスなので) FastAPI+Vercel -> Zenn-Badge ganariya
FastAPI+Vercel -> Zenn-Badge ganariya
設定ファイル {now, vercel}.json リポジトリのルートに置いてプッシュすると、Vercelが⾃動デプロイ { "version": 2, "builds": [ {
"src": "zenn_badge/app.py", "use": "@now/python" } ], "routes": [ { "src": "/.*", "dest": "zenn_badge/app.py" } ] } FastAPI+Vercel -> Zenn-Badge ganariya
FastAPI + Vercelまとめ FastAPI 型とともに過ごせる ⾮常に⾼機能でモダン Vercel 破格的無料枠 jsonファイルひとつで済む DBは外部を利⽤する
FastAPI + Vercel 開発が楽しい! FastAPI+Vercel -> Zenn-Badge ganariya
ご清聴ありがとうございました! GitHub: ganariya Qiita: ganariya Twitter: ganariya Zenn: ganariya AtCoder:
ganariya2525 FastAPI+Vercel -> Zenn-Badge ganariya