Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » IP Blacklisting Help
- Starastar
-
44 posts
IP Blacklisting Help
Hello, I am developing a web app. I have simple code to check if an IP is spamming:
I add them to the blacklist array but how do I actually black list them from visiting my web app?
if completes > 100: blacklist.append(ip)
I add them to the blacklist array but how do I actually black list them from visiting my web app?
- Starastar
-
44 posts
IP Blacklisting Help
Flask (for web development) What libraries are in use
What is this being ran on
What is this being ran with
mysql-connector-python, Pandas (for SQL)
Platform (to get stuff like the IP)
OS, Random (for specific one time use or rare uses)
Localhost!
Python?
- applejuiceproduc
-
1000+ posts
IP Blacklisting Help
Show the whole code.Flask (for web development) What libraries are in use
What is this being ran on
What is this being ran with
mysql-connector-python, Pandas (for SQL)
Platform (to get stuff like the IP)
OS, Random (for specific one time use or rare uses)
Localhost!
Python?
Generation 3: the first time you see this copy and paste it on top of your sig in the scratch forums and increase generation by 1. Social experiment.
Linux is cool
AT’s is becoming a dumpster fire

I need internet or north korea gonna blow up the world!!1!!1!1!!

- Starastar
-
44 posts
IP Blacklisting Help
whyShow the whole code.Flask (for web development) What libraries are in use
What is this being ran on
What is this being ran with
mysql-connector-python, Pandas (for SQL)
Platform (to get stuff like the IP)
OS, Random (for specific one time use or rare uses)
Localhost!
Python?
- ajskateboarder
-
1000+ posts
IP Blacklisting Help
You can use the following:
url_value_preprocessor is essentially a built-in middleware for checking a request before proceeding. This should send a 403 if a user is in the blacklist
# add this wherever your imports go from flask import request, abort
# replace "app" with name of your Flask instance if you don't use "app" @app.url_value_preprocessor def check_ban(_, _): if request.remote_addr in blacklist: abort(403)
I always seemed to get mad at people in 2022 posts and overuse things like :facepalm: If you are looking at one of those posts, just note I don't write like this anymore
software developer
artist
swimming and biking enjoyer

- Starastar
-
44 posts
IP Blacklisting Help
Thanks (wait, I should remove my set_page function when it really doesn't do much) You can use the following:# add this wherever your imports go from flask import request, aborturl_value_preprocessor is essentially a built-in middleware for checking a request before proceeding. This should send a 403 if a user is in the blacklist# replace "app" with name of your Flask instance if you don't use "app" @app.url_value_preprocessor def check_ban(_, _): if request.remote_addr in blacklist: abort(403)
- applejuiceproduc
-
1000+ posts
IP Blacklisting Help
So we can see what's wrong with your code… if there was any code.whyShow the whole code.Flask (for web development) What libraries are in use
What is this being ran on
What is this being ran with
mysql-connector-python, Pandas (for SQL)
Platform (to get stuff like the IP)
OS, Random (for specific one time use or rare uses)
Localhost!
Python?
Generation 3: the first time you see this copy and paste it on top of your sig in the scratch forums and increase generation by 1. Social experiment.
Linux is cool
AT’s is becoming a dumpster fire

I need internet or north korea gonna blow up the world!!1!!1!1!!

- Discussion Forums
- » Advanced Topics
-
» IP Blacklisting Help