How to get data from client in sockets python - python

Can you please tell me why when I try to just endlessly retrieve data from sockets, I get 2 input fields if I enter something, but if you just press enter, then outputs one?
MY CODE!!
MY ERROR!!
Already tried everything

Related

Flask server having to manually stop to run functions

I'm currently trying to make a simple flask server that gets input from the local frontend, uses the input to get certain data from a CSV, and then send the data back to the frontend. (I'm brand new to python and web development).
The issue that I'm having is this:
When I run the program, it starts the server and I go onto the frontend and post the input to the backend. It then stores the input in a variable.
I then have to manually stop the server by pressing ctrl-c. This then allows the code after it to run. (The function to get data from the CSV).
Do I then have to automatically restart the server to then send the data to the frontend? This just seems too complicated, and I've been told that you can do all this without stopping the server at all in the first place. I heavily get the sense that I'm missing the trick somewhere, however I'm new to this so pls understand :).
Please let me know if the above makes no sense and I'll try to rephrase.

FailedRequest server error 520 when sending message using PyTextNow

Over the summer, I was successfully using the PyTextNow python library to send text messages from my raspberry pi to my phone with python. I stopped using it for a while, around a month. When I tried to use it again, my phone number on TextNow had expired and I was given new one. Since then, I have been unable to use my previous code even though I made all the needed adjustments for the new phone number. I get error that looks like this: FailedRequest: Could not send message. server return a Server error. Request Failed. Status Code: 520
Here is my code
import pytextnow as pytn
client = pytn.Client(#username#, #connect.sid#)
client.send_sms("phone #", "Hello")
I have verified that the username, connect.sid cookie, and phone number are all correct numerous times. I also set up a second TextNow account, modifying the code with the new username and connect.sid values, and got the same error. I know that I am connecting to the correct account because the client.get_unread_messages() function will pull up the correct messages. To my knowledge, it is only the send message function that is not working. Any help that would enable me to send sms messages again with PyTextNow, or a better way to send and read messages in python, would be appreciated. Thanks!

Program to respond to Whatsapp messages

I need a program that detects a whatsapp message, and depending on what the message says it replies with a something different. Does anyone have any idea or code that will help me go about making this program with python?
There are many options available in order to build a WhatsApp bot using Python, however take a look at this tutorial, which is simple and gets you up and running.

Send information on program performance

I have a library known as Cyther that is doing very well, but I need to make sure that it is cross platform. To do this, I'd like to send the str variable data every time someone runs cyther, to some location that it can be viewed at a later time by me.
I also think this might be a bit risky. Should I ask the user if they wanted to send the data even though it is only one variable? I originally thought of emailing it, but the problem lied in acquiring the users email address, which is out of the question.
Is there any standard protocol for this? Is this even an ethical idea? I want this part of the program to be as simple as possible.
EDIT:
The string is Unicode, and no more than 1000 characters.
I also wouldn't want to send the info to my computer, but instead send it to a external service, or email it to me.

How to encrypt password in python?

I am writing a python script to login in my email, and I am using
M = imaplib.IMAP4_SSL('imap.gmail.com')
M.login('foo#gmail.com','123456')
however i want to let my friend use my script but i dont want him to know my password. I was wondering that is this possible?
In general, no this isn't possible, especially not if the idea is for your friend to run the script on their own computer. Your script needs to have access to the plaintext password in order to send it to the server. Whatever obfuscations you apply, anyone with access to run the script can do the same de-obfuscating as the script itself in order to retrieve it. If they have access to modify the script, they could even just change it to print exactly what you send to the server.
The only possible way around this is for you to control the full execution environment, and have the script run with different permissions than the user who can invoke it (using something like setuid Unix permissions, or even something as fully fledged as polkit). This is probably a prohibitive amount of effort compared to what you're trying to do.
ema=input("Enter your mail adress: ")
passw=input("Enter your password: ")
M = imaplib.IMAP4_SSL('imap.gmail.com')
M.login('{}'format(ema),'{}'.format(passw))
Instead of encrypt, you can use this. So your friend not have to see your password, he should enter his mail-password or you either. Or you can use getpass.getpass()

Categories