0

I have 2 programs. One runs a flask server:

from flask import Flask
from flask import request

app = Flask('app')

@app.route('/')
def hello_world():
  return 'Hello, World!'

@app.route("/send")
def receive():
  message = request.args.get('msg')
  open("msgs.txt", "a").write(str(message) + "\n\n")
  return "Sent Message"
  

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

And one that sends a request to that server:

import requests
args = {'msg': 'hi'}
url = "https://example.com/send"
x = requests.get(url, data=args).text
print(x) #Prints "Sent Message"

However, when I run the code, I just get "None" written to msgs.txt. It seems like the argument {msg : "hi"} isn't there. Why isn't it there, and how can I put it there?

  • Does this answer your question? [what is the difference between data and params in requests?](https://stackoverflow.com/questions/33496953/what-is-the-difference-between-data-and-params-in-requests) → you need `params` – mkrieger1 Feb 04 '22 at 13:06

0 Answers0