윤영준 윤영준 05-30
1. main server database data uploader.
@dee56e47123d561085f9f9837aed243e584caa9c
streaming_url_updator.py
--- streaming_url_updator.py
+++ streaming_url_updator.py
@@ -1,11 +1,15 @@
+import json
 import requests
+import textwrap
 from ITS.api import gather_cctv_list
+import urllib.parse
 
 from flask import Flask
 from flask_restx import Api
 from flask_cors import CORS
 from apscheduler.schedulers.background import BackgroundScheduler
 from apscheduler.triggers.interval import IntervalTrigger
+from requests_toolbelt.utils import dump
 
 API_ENDPOINT = "http://165.229.169.148:8080/EquipmentUrlChanger.json"
 
@@ -21,14 +25,31 @@
           )
 
 
+def print_request(req):
+    data = dump.dump_all(req)
+    print(data.decode('utf-8'))
+
 def url_list_sender():
     df = gather_cctv_list(129.2, 129.3, 35.9, 36.07, 1, "its", 1)
     df = df.drop("roadsectionid", axis=1)
     df = df.drop("cctvresolution", axis=1)
     df = df.drop("filecreatetime", axis=1)
-    payload = df.T.to_json(force_ascii=False)
-    respond = requests.post(API_ENDPOINT, json=payload)
-    print(respond)
+
+    headers = {
+        'Content-Type': 'application/json',
+        # 'User-Agent': 'PostmanRuntime/7.39.0',
+        'Accept': '*/*',
+        # 'Postman-Token': 'c9688f7d-228b-4ac7-80d2-217dec302bc8',
+        'Accept-Encoding': 'gzip, deflate, br',
+        'Connection': 'keep-alive',
+        # 'Content-Length': '5465'
+    }
+
+    payload = df.T.to_dict()
+    payload = list(payload.values())
+    payload = json.dumps(payload, indent=2)#, ensure_ascii=False) # the server in question is not using UTF-8, change it when it does.
+    response = requests.post(API_ENDPOINT, headers=headers, data=payload)
+    print_request(response)
 
 url_list_sender()
 scheduler = BackgroundScheduler()
Add a comment
List