Ask coding questions

← Back to all posts
Problem with Flask and Selenium [SOLVED]
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
EngineeredJ
Comments
hotnewtop
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 😊

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.

RayhanADev

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

RayhanADev

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

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

RayhanADev

@raaavannn hi!

I'm not sure I follow can you explain?

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!

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

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.

RayhanADev

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

RYANTADIPARTHI

@RayhanADev cool :)

RayhanADev

@RYANTADIPARTHI gg on 2000 btw

RYANTADIPARTHI