diff --git a/client/torconn.py b/client/torconn.py new file mode 100644 index 0000000..3d3b422 --- /dev/null +++ b/client/torconn.py @@ -0,0 +1,42 @@ +from torpy import TorClient +import json,requests +import struct + + +#hostname = 'ifconfig.me' # It's possible use onion hostname here as well +#port = 80 + +hostname = '128.232.229.63' #:5555' +port = 5555 + + +#from torpy.http.requests import tor_requests_session +#with tor_requests_session() as s: + + + +from torpy.http.requests import TorRequests +with TorRequests() as tor_requests: + with tor_requests.get_session() as s: + #with requests.Session() as s: + #res = s.get('http://'+hostname+':'+str(port) + '/api/followers/MrY') + #print(json.loads(res.text)) + res = s.get('http://'+hostname+':'+str(port)) + print(res,res.text) + + +# tor = TorClient() + + + +# # # Choose random guard node and create 3-hops circuit +# # try: +# # with tor.create_circuit(3) as circuit: +# # # Create tor stream to host +# # with circuit.create_stream((hostname, port)) as stream: +# # # Now we can communicate with host +# # stream.send(b'GET / HTTP/1.0\r\nHost: %s\r\n\r\n' % hostname.encode()) +# # recv = stream.recv(1024 * 10) +# # print(recv) +# # except struct.error as e: +# # print('struct error!?',e) \ No newline at end of file diff --git a/server/models.py b/server/models.py index d677821..08c14db 100644 --- a/server/models.py +++ b/server/models.py @@ -64,8 +64,8 @@ class Group(MyGraphObject): def test_models(): - x = Person(); x.name='Mr X' - y = Person(); y.name='Mr Y' + x = Person(); x.name='MrX' + y = Person(); y.name='MrY' p1 = Post(); p1.title='Post 1'; p1.content='Hello world!' p2 = Post(); p2.title='Post 2'; p2.content='Hello world!!!' p3 = Post(); p3.title='Post 3'; p3.content='Hello world!!!!!!!!!!!!' diff --git a/server/server.py b/server/server.py index 72623cd..82c364f 100644 --- a/server/server.py +++ b/server/server.py @@ -5,6 +5,13 @@ from models import * from flask_api import FlaskAPI, status, exceptions from werkzeug.security import generate_password_hash,check_password_hash + + +# works better with tor? +import json +jsonify = json.dumps +jsonify = str + # Start server app = flask.Flask(__name__) @@ -105,4 +112,4 @@ def get_post(id=None): -app.run(port=5555) \ No newline at end of file +app.run(host='0.0.0.0', port=5555) \ No newline at end of file