mirror of
https://github.com/michivonah/python.git
synced 2025-12-22 20:46:29 +01:00
document requirements & .env file
This commit is contained in:
parent
98c3163bc6
commit
edb8ed83fe
2 changed files with 36 additions and 1 deletions
|
|
@ -7,3 +7,27 @@ Check if execution is in main program
|
||||||
````python
|
````python
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
````
|
````
|
||||||
|
|
||||||
|
## Load modules
|
||||||
|
````python
|
||||||
|
import <MODULE_NAME>
|
||||||
|
````
|
||||||
|
|
||||||
|
````python
|
||||||
|
from <MODULE_NAME> import <FUNCTION>
|
||||||
|
````
|
||||||
|
|
||||||
|
## Install requirements
|
||||||
|
Create a file called `requirements.txt` in the root of the directory and add the required python modules
|
||||||
|
````text
|
||||||
|
# requirements.txt
|
||||||
|
python-dotenv
|
||||||
|
discord-webhook==1.3.0
|
||||||
|
````
|
||||||
|
|
||||||
|
Optionally you can ad == to specify the required version of the module
|
||||||
|
|
||||||
|
Install the modules with the following command:
|
||||||
|
````bash
|
||||||
|
pip install --no-cache-dir -r requirements.txt
|
||||||
|
````
|
||||||
|
|
|
||||||
11
basics/enviromment.py
Normal file
11
basics/enviromment.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Envirommental variables
|
||||||
|
# Michi von Ah - October 2023
|
||||||
|
|
||||||
|
# Import required modules
|
||||||
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
# Load variables from .env file
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
os.getenv('TEST') # Example output: Hello World!
|
||||||
Loading…
Add table
Add a link
Reference in a new issue