Amir Omidvar
Amir Omidvar

Reputation: 13

Running python script unlimitedly on cloud

I want a cloud platform to run a python script but most platforms I see has some limitations that don't allow unlimited CPU usage for a long time. is there any platform that allows this?

Upvotes: 1

Views: 178

Answers (1)

sumit03guha
sumit03guha

Reputation: 48

Apart from https://colab.research.google.com/ , depending on your usage requirement and project, you can check out https://replit.com/~ for staging your python script. After writing your main script, say main.py, you need to create another .py file and add the following code:

from flask import Flask
from threading import Thread

app = Flask('')

@app.route('/')
def home():
    return "Hello. I am alive!" #this will be printed in the webview of the replit interface.

def run():
  app.run(host='0.0.0.0',port=8080)

def keep_alive():
    t = Thread(target=run)
    t.start()

After this you need to add the keep_alive function to the last line of your main.py. Then, run the script and copy the address from the webview of replit (It is like an internal browser window).

Go to https://uptimerobot.com/ and after creating an account, Add new monitor and select Monitor type as HTTP(s), give a name, and paste the address in the URL. Check your email-id for getting notifications regarding the status of the monitor, and finally create it.

You are done! Hopefully it should work.

All the best!

Upvotes: 1

Related Questions