Skip to content
Sign upLog in
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
13

NEVER have your Python Repls go to sleep again!

c4syner
c4syner

What?

You heard that right! This ₜᵢₙᵧ addition to your program allows is it stay alive and running indefinitely.

Why?

I wanted to be able to have my discord bot stay awake without the use of external ping programs.

How?

Using a small flask server and some threaded pinging loops.

How do I get started?

Add the neverSleep.py file to your project and paste the following code to the top of your main.py:

import neverSleep neverSleep.awake('YOUR AUTO GENERATED WEBSITE URL')

That's it!
If this gets enough popularity I'll add it to PyPi to make it even easier.

3 years ago

Voters

Comments

TopNew
2
CoffeeGuy
CoffeeGuy

does this still work?? :D

2 years ago
3
c4syner
c4syner

@CoffeeGuy
Had to update it but it appears to be working now! ping me here if you need help setting it up.

2 years ago
1
Rockpods
Rockpods

@c4syner
There is a more efficient way to do this. REPLIT ENV contains REPL_SLUG and REPL_OWNER which can be used to generate the URL without input.

import os replNeverSleep.awake('https://'+str(os.environ['REPL_SLUG']).lower()+'.'+str(os.environ['REPL_OWNER']).lower()+'.repl.co', True)
8 months ago
1
c4syner
c4syner

@Rockpods
Haha I forgot about this project! Throwback to my high-school days learning Python. Anyways, that's good to know for anyone looking at this project nowadays. I'll do you one better though:

replNeverSleep.awake(f"https://{str(os.environ['REPL_SLUG']).lower()}.{str(os.environ['REPL_OWNER']).lower()}.repl.co", True)
8 months ago
1
105303058
105303058

I have tried it 10 minutes ago.
Hope this works!
Keep going!
Very appreciate!!

2 years ago
1
TobiasKosin
TobiasKosin

This is not working for me, just added the nebersleep file, imported it to my main py and used the awake method at the top. Someone got the same issue or know a working solution?

2 years ago
1
c4syner
c4syner

@TobiasKosin
Have you made sure to put your program's own url rather than mine?
(The highlighted should be changed with your own code)
image

Checked today, and this is still operational!

2 years ago
1
SixBeeps
SixBeeps

but what about node?

3 years ago
1
c4syner
c4syner

@SixBeeps
you technically could put in ANY website (including a node.js repl) and have it keep online.

3 years ago
1
SixBeeps
SixBeeps

@c4syner
I mean, considering this was written in Python, it wouldn't work. Node.js doesn't do flask.

3 years ago
1
c4syner
c4syner

@SixBeeps
No no... If you were to use a different programming language other than python. It will work because it's really just a scheduled ping program. The thing to note here is that this is outside of node.

3 years ago
1
SixBeeps
SixBeeps

@c4syner
You mentioned that you'd add this to your program to make it work. Do you mean like make another Repl to keep it alive?

3 years ago
Load more