0

This is a very simple pure python app (not Django or Flask).

What is the step-by-step and correct way of deploying this app on Openshift ?, so that it runs forever.

Code:

import requests as rq
from bs4 import BeautifulSoup as bs
import time
url = "https://apod.nasa.gov/apod/astropix.html"
page = rq.get(url).content
soup = bs(page, 'html.parser')
response = soup.find('img')
if response == None:
    imglink = soup.find('iframe')['src']
else:
    imglink = 'https://apod.nasa.gov/apod/' + response['src']
def main():
    while True:
        sess = rq.Session()
        cid='@*********'
        turl = 'https://api.telegram.org/bot****************/'
        if response == None:
            imglink = soup.find('iframe')['src']
            params = {'chat_id':cid,'text':imglink}
            sess.post(turl + 'sendMessage', data=params)
        else:
            imglink = 'https://apod.nasa.gov/apod/' + response['src']
            title = soup.find('b').get_text()
            params = {'chat_id':cid,'photo':imglink,'caption':title}
            sess.post(turl + 'sendPhoto', data=params)
        time.sleep(30)
if __name__ == '__main__':
    main()
8
  • What have you tried so far? Most of the steps provided by the open shift for deploying flask applications should be valid for this script too. Commented May 29, 2020 at 13:15
  • I dont anything about deplyment, I tried to search tutorials but they all use Django or Flask. They use some extra steps to deploy.
    – Tyolre
    Commented May 29, 2020 at 13:23
  • Try those steps, just ignore the flask part. Because those are also single page scripts with flask objects in them. Commented May 29, 2020 at 13:26
  • It uses git repo, So I dont know to create it.
    – Tyolre
    Commented May 29, 2020 at 13:33
  • You need to use git, otherwise, there is no use of having CI/CD deployment. Commented May 29, 2020 at 13:57

1 Answer 1

2

use following on commands on terminal

  1. oc login -u admin

After login in openshift cluster create new project

  1. oc new-project python

Create an application in project python

  1. oc new-app python~https:// repository url where your application is located --name myapp

get the status of created pod

  1. oc status

expose the service of pod

  1. oc expose svc/myapp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.