Skip to content

Instantly share code, notes, and snippets.

@kaniket7209
Created December 4, 2021 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaniket7209/a515b86cc7cbd829ccea12821b4c1452 to your computer and use it in GitHub Desktop.
Save kaniket7209/a515b86cc7cbd829ccea12821b4c1452 to your computer and use it in GitHub Desktop.
Hiding the MongoDB connection details from our code
1. How can we hide the MongoDB connection details from our code ?
Answer: Use an environment variable.
2. What is dotenv used for?
Answer: dotenv allows you to separate secrets from your source code. This is useful in a collaborative environment (e.g., work, or open source) where you may not want to share your database login credentials with other people. Instead, you can share the source code while allowing other people to create their own . env file.
3. What is dotenv package?
Answer: DotEnv is a lightweight npm package that automatically loads environment variables from a . env file into the process. ... To use DotEnv, first install it using the command: npm i dotenv .
4. How can we access the variable or string that is hidden using dotenv ?
Answer: First import os then by the command-> os.environ.get("var") you can access it.
5. What is Gunicorn used for?
Answer: Gunicorn is a pure-Python HTTP server for WSGI applications. It allows you to run any Python application concurrently by running multiple Python processes within a single dyno. It provides a perfect balance of performance, flexibility, and configuration simplicity.
1. Choose the correct command to install pyton dotenv?
a) pip install python_dotenv
b) pip install python-dotenv
c) pip install python-.env
d) pip install python -m .env
Answer: b)
2. Is iy neccessary to import dotenv after installing?
a) Yes
b) No
Answer: a)
3. What is teh command to load dotenv
a) load_.env()
b) load_dotenv()
c) load dotenv()
d) load_dotenv
Answer: b)
4. Is it neccessary to import os before using the variavle that we have hide and stored in dotenv file?
a) yes
b) NO
Answer: a)
5. Choose the correct statement that is used to get access of the the variable stored in dotenv file
a) os.environment.get("var")
b) os.environ.get("var")
c) os.get("var")
d) os.dotenv.get"var")
Answer: b)
6. What is the syntax of extension name to create dotenv file
a) .env.txt
b) .env.md
c) .env
d) None of the above
Answer: c)
7. Select the command to install gunicorn
a) pip install gunicorn
b) pip init gunicorn
c) npm install gunicorn
d) npm i gunicorn
Answer: a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment