.env tutorial code example
Example 1: activate venv
source env/bin/activate
Example 2: python env
python3 -m venv tutorial-env
tutorial-env\Scripts\activate.bat (window)
source tutorial-env/bin/activate (linux)
Example 3: .env tutorial
npm install dotenv --save
Example 4: .env tutorial
const express = require('express');const app = express();const port = process.env.PORT || 3000;require('dotenv').config();app.get('/', (req, res) => { res.send(process.env.SECRET_KEY);})app.listen(port, () => { console.log(`Server is running on port ${port}.`)})
Example 5: .env tutorial
require('dotenv').config()