Skip to content

Commit 037b98d

Browse files
Add server.py to duplicate functionality of server.go and interface with rappor_analysis.py
1 parent 39a37a0 commit 037b98d

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

proxy.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ func getBlockedList() (error){
9696
return err
9797
}
9898
defer resp.Body.Close()
99-
fmt.Println("Response body is: ", resp.Body)
100-
/*dec := json.NewDecoder(resp.Body)
99+
//body, _ := ioutil.ReadAll(resp.Body)
100+
//fmt.Println("Body is: ", body)
101+
dec := json.NewDecoder(resp.Body)
101102

102103

103104
// read open bracket
@@ -106,7 +107,7 @@ func getBlockedList() (error){
106107
log.Println("In getBlockedList, ", err)
107108
return err
108109
}
109-
fmt.Printf("%T: %v\n", t, t)
110+
fmt.Printf("First character type: %T, character: %v\n", t, t)
110111

111112

112113
// while the array contains values
@@ -130,7 +131,7 @@ func getBlockedList() (error){
130131
log.Println(err)
131132
return err
132133
}
133-
fmt.Printf("%T: %v\n", t, t)*/
134+
fmt.Printf("%T: %v\n", t, t)
134135
return nil
135136
}
136137

server/rappor_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def analyzeReports(filename, params, numDomains):
490490
#Keep track of the domains the LASSO selected
491491
linDoms = domains[relevantDomains]
492492
#Confirm that the domains LASSO selected are relevant using linear regression
493-
#This may prune out more domains than LASSO did
493+
#This may prune out even more domains than LASSO did
494494
finalRelevantIdxs = doLinearRegression(linX, lassY)
495495
return linDoms[finalRelevantIdxs]
496496

server/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func getBlocked(writer http.ResponseWriter, req *http.Request) {
4242
json.NewEncoder(writer).Encode(blockedList)
4343
}
4444

45+
//Adds all RAPPOR reports to a file for the python analysis script to read
4546
func addBlocked(writer http.ResponseWriter, req *http.Request) {
4647
if req.Body == nil {
4748
log.Fatal(errors.New("POST request from Metis client was empty"))

server/server.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
#!/usr/bin/python
3+
4+
from flask import Flask, request
5+
from flask_restful import Resource, Api, reqparse
6+
from json import dumps
7+
8+
app = Flask(__name__)
9+
api = Api(app)
10+
11+
parser = reqparse.RequestParser()
12+
13+
class BlockedList(Resource):
14+
def get(self):
15+
print("Request for blocked list made by client: ")
16+
return [{'Domain':'Earth'}]
17+
18+
def post(self):
19+
print("Client sent RAPPOR things to us: ")
20+
args = parser.parse_args()
21+
print(args)
22+
return '', 200
23+
24+
api.add_resource(BlockedList, "/blocked")
25+
print("Starting Metis server...")
26+
app.run(debug=True)
27+

0 commit comments

Comments
 (0)