#!usr/bin/env Python
# -*- coding: utf-8 -*-
f=["acces-cam1-1465842425990.json", 	
"acces-cam1-1465842462451.json",
"acces-cam1-1465842477315.json",
"acces-cam1-1465843720080.json",
"acces-cam1-1465843721594.json",
"acces-cam1-1465843727631.json",
"acces-cam1-1465844502503.json",
"acces-cam1-1465844533374.json",
"acces-cam1-1465848459311.json",
"acces-cam1-1465848461501.json",
"acces-cam1-1465848537041.json",
"acces-cam1-1465849023774.json"]
import os, sys, re, urllib2,sys,json
import subprocess, threading,time,os
directori = "/home/oriol/TreballFinalDeGrau/AccesNucliAntic/json_prova/"
listfichero = os.listdir(directori)
for fitcher in f:
  time.sleep(1)
  read = open(directori+fitcher, 'r')
  postdata = json.load(read)
  URL = "http://localhost:8000/acces"
  req = urllib2.Request(URL)
  req.add_header('Content-Type','application/json')
  data = json.dumps(postdata)
  response = urllib2.urlopen(req,data)