Skip to content

Instantly share code, notes, and snippets.

View kaniket7209's full-sized avatar
🎯
Focusing

kaniket7209

🎯
Focusing
View GitHub Profile
@kaniket7209
kaniket7209 / test.js
Created November 22, 2022 04:58
JAVASCRIPT TEST
// You have been given a sample data and the list of selected values. Your task will be to make the query for mongo collection.
// this is the sample value
let unique_fields = [
{"key":"priority","operator":["==","!="],"type":"str","value":["normal","high","low","urgent"]},
{"key":"status","operator":["==","!="],"type":"str","value":["open","pending"]},
{"key":"account_domain","operator":["==","!="],"type":"str","value":["renault.co.in","rivian.com","lucidmotors.com",
"mercedes-benz.com","zoox.com","tata.com","bmw.com","kia.com","tesla.com","honda.com","toyota.com"]}
]
@kaniket7209
kaniket7209 / .ejs file
Created April 12, 2022 10:43
Dashboard
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SIYA | Dashboard </title>
<head>
@kaniket7209
kaniket7209 / FAQ
Created December 7, 2021 04:24
What is flask-limiter
1. What will happen if the rate limit strings that are provided to the Limiter.limit() decorator are malformed and can’t be parsed ?
Answer: Then the decorated route will fall back to the default rate limit(s) and an ERROR log message will be emitted.
2. What is exemption condition?
Answee: Each limit can be exempted when given conditions are fulfilled. These conditions can be specified by supplying a callable as an `exempt_when` argument when defining the limit.
3. What is key_func ?
Answer: key_func is a callable that returns the domain to rate limit by.
4. What is exempt?
@kaniket7209
kaniket7209 / FAQ
Created December 5, 2021 17:12
SEND EMAILS USING FLASK-MAIL
1. How can we set up Mail instance using init_app method
Answer: Use below command:
mail = Mail()
app = Flask(__name__)
mail.init_app(app)
2. Why 'ConnectionRefusedError:[WinError 10061]' occurs and how to fix it?
Answer: Based on the description of the error, this is not a problem with your Python code, but rather that the network connection to smtp.gmail.com is being blocked/rejected (possibly by a firewall or some other network issue).
Note that if you are running this on a home machine, most ISPs will actively block outbound SMTP connections to anything except the ISP's own SMTP servers (some hosting providers also do the same), to prevent spammers from exploiting the service. You may need to change your settings to use your ISP's outbound mail host instead of connecting directly to smtp.gmail.com.
@kaniket7209
kaniket7209 / FAQ
Created December 4, 2021 08:10
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 ?
@kaniket7209
kaniket7209 / FAQ
Created December 4, 2021 06:05
Deploying our app to Heroku
1. How do I deploy a Python app to Heroku?
Answer: Deployment Steps
a) Login to your Heroku account using CLI. ...
b) Create a web app on Heroku. ...
c) Create requirements.txtfile in the same project directory. ...
d) Create a Procfile. ...
e) Create runtime.txt to specify the Python version at runtime. ...
f) Initialize an empty git repository and push the code.
2. How do I deploy an existing app to Heroku?
@kaniket7209
kaniket7209 / FAQ
Created December 4, 2021 05:41
Getting our App ready for Heroku
1. What is Procfile in node?
Answer: Procfile is a mechanism for declaring what commands are run by your application's dynos on the Heroku platform.
2. How do I run a Procfile locally?
Answer: To start your app locally follow the below steps:
a) To use a different Procfile, use the -f flag: heroku local -f Procfile. test .
b) To use a different environment file, use the -e flag: heroku local -e . env. test .
c) To use a different port, use the -p flag: heroku local -p 7000 . If you don't specify a port, 5000 is used.
3. Where do I put Procfile?
@kaniket7209
kaniket7209 / FAQ
Created December 4, 2021 05:12
What is Heroku?
1. Who can make request?
Answer: Anyone who has access to the computer running the app can make request.
2. What is Dynos?
Answer: The containers used at Heroku are called “dynos.” Dynos are isolated, virtualized Linux containers that are designed to execute code based on a user-specified command. ... Dynos are the building blocks that power any Heroku app, from simple to sophisticated.
3. Why is Heroku useful?
Answer: Heroku is useful because:
a) We can put our code in their servers
b) We can run our flask apps continuously
@kaniket7209
kaniket7209 / FAQ
Created December 3, 2021 20:09
What is the requirements.txt file?
1. What is requirement file?
Answer: A requirements file is a list of all of a project's dependencies. This includes the dependencies needed by the dependencies. It also contains the specific version of each dependency, specified with a double equals sign ( == ).
Logically, a Requirements file is just a list of pip install arguments placed in a file. Note that you should not rely on the items in the file being installed by pip in any particular order.
2. Why we need requirement.txt?
Answer: It helps us in several ways, even when we revisit our project in the future, as it solves almost all compatibility issues. If you ever work on any Python project or developed any project, you surely know that we usually require several numbers of packages. However, while developing a project, we generally used a particular version of packages. Later on, the package manager or maintainer may make some changes, and these modifications can easily break your entire application. Therefore it is too much work to keep track of e
@kaniket7209
kaniket7209 / FAQ
Created December 3, 2021 19:40
How to use Flask's app factory Pattern
1. What is Flask?
Answer: Flask is a light-weight web framework. With Flask, you get to pick-and-choose what components and extension needed for your site. I like this aspect since the modular nature allows you to build everything up, without too much clutter.
2. What is app Factory Flask?
Answer: The Flask Application Factory refers to a common "pattern" for solving this dilemma. ... For Flask to recognize the data models we have in models.py , our Blueprints, or anything else, Flask needs to be told that these things exist after the app is "created" with app = Flask(__name__) .
3. How can we use Flask's app Factory pattern in our code?
Answer: Just wrap your code under the following command
def create_app():
#Your app.py code