Skip to content
Sign upLog in
← Back to Community

Problem with Flask and Selenium [SOLVED]

Profile icon
EngineeredJ

Hey guys,

my current project is a discord bot that can start my Minecraft server (which Im hosting on exaroton) with a message like !start in my server.

OK, that's not the problem. But I have a keepalive file in which I host a small flask web app so that I can ping that site from time to time and see if its still working (and keep my bot running for free don't tell anyone pls).

So here's my problem: my bot needs to open a browser, login and click a button. I use Selenium and it works fine but my Flask web app just stops working. When I comment out the Selenium part everything works fine again...

Is there a problem with running Flask and Selenium at the same time? Thanks for any help. I don't know if I need to upload my code.

Voters
Profile icon
EngineeredJ
Comments
hotnewtop
Profile icon
RayhanADev

Hi
@EngineeredJ

Kewl project. Okay so what’s happening is your Flask App is running along with Selenium. Do you see the problem. If not, let me explain: you have two webserver projects running in one Repl which is a big nono. Not acceptable. That’s why “one stops working”. You can’t see it because a Repl can only run one web server at a time.
Also it’s generally a good idea to upload code 😊

Profile icon
EngineeredJ

@RayhanADev

Hey,
thanks for the quick answer! I put selenium in headless mode and it works great again. Wasn't expecting an answer so quick haha.

Profile icon
RayhanADev

@EngineeredJ
lmao I’m pretty speed aren’t I xD. Glad you figured it out!

Profile icon
RayhanADev

@EngineeredJ
hey since you figured it out mind marking this as answered so nobody else thinks you’re still confuzzled xD.

Profile icon
raaavannn

@RayhanADev

i'm sorry if i missed something, but i tried making selenium headless and disabled gpu, though still it doesn't seem to work..
here's my repl link.. selenium is only used in: ./contests/codechef.py
https://replit.com/@raaavannn/senpai-discord-bot#contests/codechef.py

Profile icon
RayhanADev

@raaavannn
hi!

I'm not sure I follow can you explain?

Profile icon
TheWasian1

@RayhanADev
I'm running into the same issue with Selenium Chrome/Chromedriver. Tried headless to no avail. Do you think you'd be able to provide any insight/input? https://replit.com/@TheWasian1/Bot-with-Cogs?v=1

Profile icon
pvnt

My Repl was worked after removed and restored from trash. But it could start Flask and able to access URL.
But after we call to Selenium Function, It were unreachable! So weird! Just showed Fluxbox!

image

Profile icon
chethansai

Tried with headless too. Did not work. Does anyone has clean solution yet?

Profile icon
HerreraCarlos81

Hello guys, sorry but since there is no attached link to a solution, can anyone confirm if you were able to run flask and selenium on a repl ? Even when I use headless as suggested, it does not work.

This is my repl link
https://replit.com/join/zhbystzk-herreracarlos81

Profile icon
RYANTADIPARTHI

uh did you figure it out? If you didn't tell me, and I'll just explain. but if you did solve it, let me know.

Profile icon
RayhanADev

@RYANTADIPARTHI
they did (and I helped!!! I think im gonna get back into answering people’s questions 😊)

Profile icon
RYANTADIPARTHI

@RayhanADev
cool :)

Profile icon
RayhanADev

@RYANTADIPARTHI
gg on 2000 btw

Profile icon
RYANTADIPARTHI

@RayhanADev
thx.

Profile icon
RiderFloor

@RayhanADev
So what is the solution?

Profile icon
mrzpzp

@RYANTADIPARTHI
hey, do you have the solution?

Profile icon
mrzpzp

@RayhanADev
hey, do you have the solution?