mirror of
https://github.com/kennethreitz-archive/python-localtunnel.git
synced 2026-06-05 23:40:17 +00:00
http client
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
localtunnel.http
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
This module provides
|
||||
"""
|
||||
|
||||
import requests
|
||||
|
||||
from .packages.omnijson import loads as from_json
|
||||
from .packages.omnijson import JSONError
|
||||
|
||||
|
||||
LOCALTUNNEL_API = 'http://open.localtunnel.com/'
|
||||
|
||||
|
||||
def register_key(pub_key):
|
||||
"""Publishes a public key to the localtunnel service."""
|
||||
|
||||
r = requests.post(LOCALTUNNEL_API, data={'key': pub_key})
|
||||
r.raise_for_status()
|
||||
|
||||
|
||||
def register_tunnel():
|
||||
"""Requests a new connection to the localtunnel service."""
|
||||
r = requests.get(LOCALTUNNEL_API)
|
||||
|
||||
try:
|
||||
return from_json(r.content)
|
||||
except JSONError, why:
|
||||
raise why
|
||||
|
||||
Reference in New Issue
Block a user