Ask coding questions

← Back to all posts
Problem with Flask and Selenium [SOLVED]
EngineeredJ (0)

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.

Comments
hotnewtop
RayhanADev (2517)

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 😊

EngineeredJ (0)

@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.

RayhanADev (2517)

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

RayhanADev (2517)

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

pvnt (0)

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!

HerreraCarlos81 (0)

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

RYANTADIPARTHI (6018)

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.

RayhanADev (2517)

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