Created
August 9, 2023 19:23
-
-
Save wiljdaws/ee66829c06c5c7d185771260d02ecc03 to your computer and use it in GitHub Desktop.
Post Json Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import os | |
import requests | |
directory = "/data/feedback" | |
for filename in os.listdir(directory): | |
if filename.endswith(".txt"): | |
with open(os.path.join(directory, filename)) as file: | |
lines = file.readlines() | |
title = lines[0].strip() | |
name = lines[1].strip() | |
date = lines[2].strip() | |
feedback = lines[3].strip() | |
data = {"title": title, "name": name, "date": date, "feedback": feedback} | |
res = requests.post("http://35.233.238.127/feedback/", data=data) | |
print("status_code ",res.status_code) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment