This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, jsonify, g, request | |
from sqlite3 import dbapi2 as sqlite3 | |
DATABASE = './db/test.db' | |
app = Flask(__name__) | |
def get_db(): | |
db = getattr(g, '_database', None) | |
if db is None: | |
db = g._database = sqlite3.connect(DATABASE) | |
db.row_factory = sqlite3.Row |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# reddit27_samp.py | |
# http://docs.python.org/release/2.5.2/lib/httplib-examples.html | |
import httplib | |
url_string = "www.reddit.com" | |
header_stuff = {"User-Agent":"blah blah blah"} | |
reddit_feed = "/r/skydiving.json" | |
conn = httplib.HTTPConnection(url_string) | |
conn.request(method="GET", url=reddit_feed, headers=header_stuff) | |
res = conn.getresponse() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib, urllib, json | |
def makeRequest() : | |
url = "iphone.kinoafisha.info" | |
req = "/server.php" | |
data = { | |
'method' : "beginSession" | |
, 'params' : [ { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from httplib import HTTPConnection | |
import json | |
if __name__ == '__main__': | |
base_url = '/challenge.json' | |
url = base_url | |
count = 0 | |
conn = HTTPConnection('www.letsrevolutionizetesting.com') | |
while count < 100: | |
conn.request("GET", url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
# Author: --<> | |
# Purpose: | |
# Created: 2013/7/3 | |
import sys | |
import httplib | |
import json | |
import urllib | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib | |
import base64 | |
import string | |
import urllib | |
host = "api.supertweet.net" | |
url = "/1.1/statuses/update.json" | |
username = 'INPUTUSERNAME' | |
password = 'INPUTPASSWORD' | |
message = 'Tweet by Python on Raspberry Pi' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import BaseHTTPServer | |
from BaseHTTPServer import BaseHTTPRequestHandler | |
from urlparse import parse_qs | |
import httplib, urllib | |
import json | |
PARAMS_STRING = "?redirect_uri=http://127.0.0.1&client_secret=[SECRET]&client_id=[CLIENT_ID]&grant_type=authorization_code&code=" | |
class Handler(BaseHTTPRequestHandler): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64, httplib, json, xmlrpclib | |
class ApiBase(object): | |
def __init__(self, host, login, password, port=10000, https=True): | |
self.host = host | |
self.login = login | |
self.password = password | |
self.port = port | |
self.https = https | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Selenium2TestCase(TestCase): | |
def report_pass_fail(self): | |
base64string = base64.encodestring('%s:%s' % (config['username'], | |
config['access-key']))[:-1] | |
result = json.dumps({'passed': self._exc_info() == (None, None, None)}) | |
connection = httplib.HTTPConnection(self.config['host']) | |
connection.request('PUT', '/rest/v1/%s/jobs/%s' % (self.config['username'], | |
self.driver.session_id), | |
result, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# - * - coding: UTF-8 - * - | |
import json | |
import urllib | |
import oauth2 as oauth | |
# 此行用于获取 CONSUMER_KEY、CONSUMER_SECRET 等常数 | |
from config import * | |
OlderNewer