In javascript/typescript I like to combine all ways to provide environment variables, using a sweet library called yargs :D
yargs
import dotenv from "dotenv" import yargs from "yargs" import fs from "fs" dotenv.config() const args = yargs .env() // parse process.env .middleware((argv) => { const configPath = "./config.json" if(fs.existsSync(configPath)){ try { // parse options from config file return { ...JSON.parse(fs.readFileSync(configPath, 'utf-8')), ...argv } } catch(e){ console.error('Error parsing config file') } } return argv }, true) .options({ 'port': { alias: 'p', type: 'number', default: 80 }, 'corsOrigin': { alias: 'o', type: 'string', default: "http://localhost:3000" }, // etc... parses command line options }) .help() .argv
not sure if such a library exists for python though.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In javascript/typescript I like to combine all ways to provide environment variables, using a sweet library called
yargs
:Dnot sure if such a library exists for python though.