Python Forum
Controlling Python Program From Django Front End
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controlling Python Program From Django Front End
#1
Hi,

I am working on a project for which I have written the back end in python socket programming an multi threading. For the same project I am writing Django based website now.

My requirement is I need to control the back end script from django website. What the back end script does is.. it does telnet to some network elements fires some commands and get the relevant data which is further stored in a sqlite db created for each run.

Now I was thinking of overloading system interrupts in the back end script like SIGTERM and all. After that from django start the script and save its PID. Further to send signals to that script django will send system interrupts(Overloaded in back end script) to that PID. Based on which the back end script will do some action.

The problem what I am seeing in this approach is, its one way communication. If any error, for example if login to network element failed in back end script. There is no way for django to know that.

Sorry for so much text. But I needed to explain my understanding.

Can anyone please guide me right direction. I am very new to django and python and short on time to complete this project.

Thanks a lot in advance.

Regards, Jaiswal
Reply
#2
Hello. You can establish some kind of secure connection between the script and the website. Both can communicate using JSON to each other. For example. You can easily send commands which the script can understand and get back the output.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
Hi,
Thanks for the reply.

But I am new to this type of communication and I have not worked on JSON.
Can you please explain a bit.
I tried googling what you suggested but dint find anything helpful.

Regards,
Jaiswal
Reply
#4
Just like any other program, this one could listen to a port for a connection from the website for some message which can be interpreted as a command. After that, it does its things and returns a response back to the website which you can see.
JSON stands for JavaScript Object Notation. Perhaps every programming language can deal with it. It has a simple structure, it's human-readable and consists of key-value pairs. It looks like this:

"person" {
    "first": "Donald",
    "last": "Trump",
    "characteristics": ["president of the USA", "businessman"]
    }
The messages could be a simple text too. It depends on what suits your needs.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  The function of double underscore back and front in a class function name? Pedroski55 9 622 Feb-19-2024, 03:51 PM
Last Post: deanhystad
  Controlling program with TCP commands lavacode 1 543 Jul-10-2023, 04:39 PM
Last Post: deanhystad
  front-end js and back-end python 3lnyn0 0 988 Jun-03-2022, 08:51 PM
Last Post: 3lnyn0
  Controlling text-to-speech pauses with pyttsx3 pmac1300 4 4,434 Mar-14-2022, 06:47 AM
Last Post: Coricoco_fr
  Controlling what get outputted to stdout when running external commands Daring_T 4 2,159 Jan-30-2022, 05:40 PM
Last Post: bowlofred
  Looking For Help On Controlling Philips Hue From PyCharm RickyRay333 4 3,774 Aug-24-2020, 08:33 PM
Last Post: Nickd12
  controlling multiple server simultaneously. caligola 3 3,600 May-11-2018, 05:44 PM
Last Post: wavic
  Controlling trailing zeros with rounding? RedSkeleton007 1 24,485 Jan-25-2018, 07:23 AM
Last Post: j.crater

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020