sudo apt-get install python3-pip
sudo pip3 install virtualenv
| import boto3 | |
| import pandas as pd | |
| from io import BytesIO | |
| bucket, filename = "bucket_name", "filename.csv" | |
| s3 = boto3.resource('s3') | |
| obj = s3.Object(bucket, filename) | |
| with BytesIO(obj.get()['Body'].read()) as bio: | |
| df = pd.read_csv(bio) |
| from myapp.utils import set_current_user | |
| class CurrentUserMiddleware: | |
| def process_request(self, request): | |
| set_current_user(getattr(request, 'user', None)) | |
| import requests | |
| headers = { | |
| 'Authorization': 'Token c0efa4be06a92f8b60dc4f818b30eb468041fdd7' | |
| } | |
| def getToken(username, password): | |
| url = f"http://127.0.0.1:8000/api-token-auth/ username={username} password={password}" |
| # settings.py | |
| # Step-1 | |
| ###################################################################################################################### | |
| INSTALLED_APPS = [ | |
| 'rest_framework', | |
| 'rest_framework.authtoken' | |
| ] | |
| $RequestHeader = @{}; | |
| $RequestHeader.Add("Authorization", "token c0efa4be06a92f8b60dc4f818b30eb468041fdd7"); | |
| $api_host = "http://localhost:8000" | |
| #$final_url = "{0}{1}" -f $api_host,'/api/cart-items/' | |
| #Invoke-RestMethod http://localhost:8000/api/cart-items/ -Method GET -Header(@{"Authorization" = "token c0efa4be06a92f8b60dc4f818b30eb468041fdd7"}) | |
| ################################################################################################################################# | |
| #GET Method for Fetch All objects | |
| $GetAllUrl = "$api_host/api/cart-items/" | |
| #Invoke-RestMethod $GetAllUrl -Method GET -Headers $RequestHeader |
| import threading | |
| import time | |
| # backup_config = { | |
| # "backup_pc": ["PC-10", "PC-20", "PC-30"], | |
| # "back_up_timer": [2, 4, 3] | |
| # } | |
| # print(backup_config['backup_pc']) |
| from concurrent.futures import ThreadPoolExecutor | |
| import time | |
| def wait_function(x, y): | |
| print('Task(', x,'multiply', y, ') started') | |
| time.sleep(2) | |
| print('Task(', x,'multiply', y, ') completed') | |
| return x * y | |
| def callback_function(future): |
| $ git clone [email protected]:xxxxx/xxxx.git my-awesome-proj | |
| Cloning into 'my-awesome-proj'... | |
| ssh: connect to host github.com port 22: Connection timed out | |
| fatal: Could not read from remote repository. | |
| $ # This should also timeout | |
| $ ssh -T [email protected] | |
| ssh: connect to host github.com port 22: Connection timed out | |
| $ # but this might work |
| [settings] | |
| DEBUG=True | |
| SECRET_KEY=y#bz$z0prv)@bie(@3wa@=--ana7%%k!hvo)b-3d4#0mnhh0pi6 | |
| AWS_ACCESS_KEY_ID=M5YCPZP3QT36OWMMZS23 | |
| AWS_SECRET_ACCESS_KEY=5Npq/S/7tX2IqBl51p3QEAMJuuGvHuFH4680Cl59M3s | |
| AWS_STORAGE_BUCKET_NAME=open-api-space | |
| AWS_S3_ENDPOINT_URL=https://nyc3.digitaloceanspaces.com | |
| AWS_LOCATION=open-api-static |