forked from Crowd-Control-NEU/crowd-control-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopulateLongterm.py
39 lines (32 loc) · 1.39 KB
/
populateLongterm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from datetime import datetime, date, timedelta, time
from urllib import request, parse
import json
import time as t
import random
API_ENDPOINT_LOCAL = 'http://localhost:5000/data-add'
API_ENDPOINT_PRODUCTION = 'https://infinite-peak-11670.herokuapp.com/data-add'
API_TO_USE = API_ENDPOINT_PRODUCTION
location = 'Matthews Arena'
days = 1000
date_to_send = ''
for x in range(59,days):
date = date.today() - timedelta(days=x)
min_pub_date_time = datetime.combine(date, time.min)
time = datetime.time(min_pub_date_time + timedelta(minutes=15))
date_to_send = datetime.combine(min_pub_date_time, time)
randomCount = random.randint(150, 300)
data = parse.urlencode({'count': randomCount, 'location_name': location, 'date': date_to_send}).encode()
req = request.Request(API_TO_USE, data=data) # this will make the method "POST"
resp = request.urlopen(req)
# Convert bytes to string type and string type to dict
string = resp.read().decode('utf-8')
print(string)
t.sleep(.0001)
# data = parse.urlencode({'count': randomCount*-1, 'location_name': location, 'date': date_to_send}).encode()
# req = request.Request(API_TO_USE, data=data) # this will make the method "POST"
# resp = request.urlopen(req)
# Convert bytes to string type and string type to dict
# string = resp.read().decode('utf-8')
# print(string)
# t.sleep(.0001)
print('DAY:', x)