Completed
Push — master ( c4019d...466f9c )
by Gus
01:16
created

full_path()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 2
rs 10
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
from __future__ import unicode_literals
4
import requests
5
import json
6
import os
7
8
def post_json(service, json_data):
9
    # POST json to the server API
10
    #response = requests.post(service, json={"text":"{}".format(text)})
11
    # for older versions of requests, use the call below
12
    #print("SERVICE: {}".format(service))
13
    response = requests.post(service,
14
                             data=json_data,
15
                             headers={'content-type': 'application/json; charset=utf-8'},
16
                             timeout=None
17
                             )
18
    # response content should be utf-8
19
    #response.encoding = "utf-8"
20
    content = response.content.decode("utf-8")
21
    #print("CONTENT: {}".format(content))
22
    return json.loads(content)
23
24
def full_path(p):
25
    return os.path.abspath(os.path.expanduser(p))
26