Skip to content

Instantly share code, notes, and snippets.

@ayafujiaya
Last active December 26, 2015 08:09
Show Gist options
  • Save ayafujiaya/7120112 to your computer and use it in GitHub Desktop.
Save ayafujiaya/7120112 to your computer and use it in GitHub Desktop.
Codes which I store json data to fluentd-json-receiver ( https://github.com/HOUSE-API-Project/fluentd-json-receiver ) by POST method.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import requests
import json
from requests.auth import HTTPBasicAuth
url = 'http://133.242.144.202/post'
payload = {'tag':'shibuhouse.testpost', 'data':'{"moge":"hoge"}'}
headers = {'content-type': 'application/json'}
auth = HTTPBasicAuth("user","password")
r = requests.post(url, data=json.dumps(payload), headers=headers, auth=auth)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment