Skip to content

Instantly share code, notes, and snippets.

View subnetmarco's full-sized avatar
🦍
Hiring, Thinking, Coding

Marco Palladino subnetmarco

🦍
Hiring, Thinking, Coding
View GitHub Profile
@subnetmarco
subnetmarco / gist:3693500
Created September 10, 2012 20:08
Flask Upload Sample
import os
from flask import Flask, request, redirect, url_for
from werkzeug import secure_filename
UPLOAD_FOLDER = '/tmp'
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
@app.route("/upload", methods=['POST'])
#import "Weather.h" // Let's import the API client implementation
@interface sample : NSObject
+ (void) doSomething;
@end
@implementation sample
+ (void) doSomething {
@subnetmarco
subnetmarco / sample.h
Created September 20, 2012 23:28
sample.h
#import "Weather.h"
@interface sample : NSObject <MashapeDelegate>
- (void) doSomething;
@end
@subnetmarco
subnetmarco / sample.m
Last active October 10, 2015 22:17
sample.m
#import "sample.h"
@implementation sample
-(void)requestCompleted:(MashapeResponse*) response {
// The MashapeResponse has the following properties that you can use
NSLog(@"The HTTP status code is %d", [response code]);
NSLog(@"The HTTP headers are %@", [response headers]);
NSLog(@"The HTTP parsed body is %@", [response body]);
NSLog(@"The HTTP raw body is %@", [response rawBody]);
// The parsed response body is a NSArray of NSDictionary
NSLog(@"%@", [[[response body] objectAtIndex:0] objectForKey:@"condition"]);
// Initialize the client object with your Mashape public and private keys.
Weather weatherClient = new Weather("YOUR-MASHAPE-KEY");
// Invoke the method and get back the MashapeResponse object
MashapeResponse<JSONArray> response = weatherClient.getForecasts("San Francisco");
// The MashapeResponse has the following properties that you can use
int code = response.getCode(); // The HTTP status code
Map<String, String> headers = response.getHeaders(); // The HTTP response headers
JSONArray body = response.getBody(); // The parsed body
// Initialize the client object with your Mashape public and private keys.
Weather weatherClient = new Weather("YOUR-MASHAPE-KEY");
Thread thread = weatherClient.getForecasts("San Francisco", new MashapeCallback<JSONArray>() {
public void requestCompleted(MashapeResponse<JSONArray> response) {
// The MashapeResponse has the following properties that you can use
int code = response.getCode(); // The HTTP status code
Map<String, String> headers = response.getHeaders(); // The HTTP response headers
System.out.println(response.getBody().getJSONObject(0).getString("condition"));
require File.join(File.dirname(__FILE__), "Weather.rb") # Let's import the API client implementation
# Initialize the client object with your Mashape public and private keys.
obj = Weather.new("YOUR-MASHAPE-KEY")
# Invoke the method and get back the response object
response = obj.getForecasts("San Francisco")
# The response object has the following properties that you can use
puts response.code # The HTTP Status code
require File.join(File.dirname(__FILE__), "Weather.rb") # Let's import the API client implementation
# Initialize the client object with your Mashape public and private keys.
obj = Weather.new("YOUR-MASHAPE-KEY")
# Invoke the method and get back the response object
thread = obj.getForecasts("San Francisco") { |response|
# The response object has the following properties that you can use
puts response.code # The HTTP Status code