0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[🔰][備忘録]FastAPIは.envをモジュール使わないと読み込んでくれないらしい

Posted at

状況

APIキーとかを.envに入れて環境変数として取り出そうとしてました。FastAPIを挟まずにテストでプログラムを実行した時はちゃんとやりたいことができていたのに、FastAPI使ってAPI化すると
Internal Server Error.
は?
Internal Server Error.
ha?

解決方法

from dotenv import load_dotenv

load_dotenv()
これでいつも通りos.getenv("hogehoge")で呼び出せるようになるそうです。
よかったね😊

結論

ちゃんとドキュメント読んで検索しまくってAIに聞いていこう!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?