This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import g, current_app | |
| from db import DB | |
| def get_db(): | |
| if 'db' not in g: | |
| g.db = DB() | |
| return g.db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import string | |
| letters = [] | |
| letters.extend(string.ascii_lowercase) | |
| letters.extend(string.ascii_uppercase) | |
| letters.extend((str(i) for i in range(0, 10))) | |
| print(letters) | |
| print(''.join([random.choice(letters) for i in range(50)])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import hashlib | |
| hashed_str1 = hashlib.sha256('text123hello'.encode('utf-8')).hexdigest() | |
| print(hashed_str1) | |
| hashed_str2 = hashlib.sha256('text123hello'.encode('utf-8')).hexdigest() | |
| print(hashed_str2) | |
| assert hashed_str1 == hashed_str2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| logging.basicConfig(format='%(asctime)s::%(name)s::%(levelname)s::%(message)s', level='INFO') | |
| logger = logging.getLogger(__name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "version": 2, | |
| "builds": [ | |
| { | |
| "src": "main.py", | |
| "use": "@vercel/python" | |
| } | |
| ], | |
| "routes": [ | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # main.py | |
| from fastapi import Depends, FastAPI, HTTPException | |
| from sqlalchemy.orm import Session | |
| from database import SessionLocal, engine | |
| import crud, models, schemas | |
| models.Base.metadata.create_all(bind=engine) | |
| app = FastAPI() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| li = ["Ram", 12, [23, 56, "vinod"], [[12, "you"], 1], [["mnb"], | |
| ["kjhdsf", 123, 0.8876], [[98, 12, 34], [2345, 8987643]]]] | |
| lo = [] | |
| def flatten_list(li): | |
| for i in li: | |
| if isinstance(i, list): | |
| flatten_list(i) | |
| else: |
OlderNewer