Last active
April 7, 2019 11:42
-
-
Save sanjeevsiva17/2ee7076559c3fe47f6ea6aa452f3d2f0 to your computer and use it in GitHub Desktop.
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 http.server import HTTPServer, BaseHTTPRequestHandler | |
import pymongo | |
import json | |
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): | |
def do_GET(self): | |
self.send_response(200) | |
self.end_headers() | |
self.wfile.write(b'Hello, world!') | |
relation = [] | |
d = {} #final dictionary | |
db_connect = pymongo.MongoClient('localhost', 27017) | |
database_name = 'NASTY' | |
database = db_connect[database_name] | |
collection = database.collection_names(include_system_collections=False) | |
for collect in collection: | |
record1 = database[collect] | |
cursor = record1.find({}) | |
for doc in cursor: | |
print() | |
relation.append(doc['relations']) | |
d = dict([(collect, relation)]) | |
print d | |
def do_POST(self): | |
self.send_response(200) | |
self.end_headers() | |
self.wfile.write(b'WTF!!') | |
httpd = HTTPServer(('localhost', 8000), SimpleHTTPRequestHandler) | |
httpd.serve_forever() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment