How to Properly Configure httpx URL in Settings for a Python Project?

10 Replies, 2294 Views

Hey! For the httpx url in settings python, I’d recommend using environment variables. It’s way cleaner and safer, especially if you’re dealing with different environments like dev and prod.

You can use a `.env` file and load it with `python-dotenv`. Here’s a quick example:

```python
from dotenv import load_dotenv
import os

load_dotenv()
URL = os.getenv('HTTPX_URL')
```

This way, you can keep your URLs out of your codebase and manage them easily. Check out the `python-dotenv` docs for more details!

Messages In This Thread



Users browsing this thread: 1 Guest(s)