I am writing a Flask code on pythonanywhere and I don't no if it's my program or pythonanywhere the problem. The problem is that the file "db_game.txt" is empty. Here is my code: flask_app.py:
import flask
app = flask.Flask(name)
@app.route('/', methods=['POST'])
def server(): data = flask.request.get_json()
with open("db_game.txt", "a") as f:
f.write(str(data))
print("data:",data)
return data
requests.py:
import requests import json
URL = "http://me.pythonanywhere.com"
d = json.dumps({"one": "two"}) response = requests.post(URL, json=d) print(response.text)
db_game.txt: