{"action":"created","comment":{"url":"https://api.github.com/repos/jeremytedwards/http-server/pulls/comments/55946970","id":55946970,"diff_hunk":"@@ -0,0 +1,162 @@\n+from __future__ import unicode_literals\n+\n+import socket\n+import email.utils\n+import mimetypes\n+import io\n+import os\n+\n+\n+def build_file_structre_html(directory):\n+    print(directory)\n+    body = \"<!DOCTYPE html>\\r\\n<html>\\r\\n<ul>\\r\\n<body>\\r\\n<h1>Code Fellows</h1>\\r\\n\"\n+    for item in os.listdir(directory):\n+        print(item)\n+        if os.path.isdir(os.path.join(directory, item)):\n+            body += \"<li><a href=\\\"{}/\\\">{}</a></li>\\r\\n\".format(item, item)\n+        else:\n+            body += \"<li><a href=\\\"{}\\\">{}</a></li>\\r\\n\".format(item, item)\n+    body += \"</ul>\\r\\n</body>\\r\\n</html>\"\n+    return body\n+\n+\n+def response_template():\n+    return [u\"\",\n+            u\"\" + str(\"Date: \" + email.utils.formatdate(usegmt=True) + \"\\r\\n\"),\n+            u\"Content-type: text/html; charset=utf-8\\r\\n\",\n+            u\"Content-length: \\r\\n\\r\\n\",\n+            u\"Body: \"]\n+\n+\n+def response_check(error):\n+    response_dict = {\n+        \"200\": u\"HTTP/1.1 200 OK\\r\\n\",\n+        \"400\": u\"HTTP/1.1 400 Bad Request\\r\\n\",\n+        \"404\": u\"HTTP/1.1 404 File Not Found\\r\\n\",\n+        \"405\": u\"HTTP/1.1 405 Method Not Allowed\\r\\n\",\n+        \"500\": u\"HTTP/1.1 500 Internal Server Error\\r\\n\",\n+        \"505\": u\"HTTP/1.1 505 HTTP Version Not Supported\\r\\n\",\n+    }\n+    return response_dict[error]\n+\n+\n+def parse_request(request):\n+    split_request = request.split('\\r\\n')\n+    request_list = split_request[0].split(' ')\n+    if request_list[0] == 'GET':\n+        if request_list[2] == 'HTTP/1.1':\n+            if 'Host: 127.0.0.1:' in split_request[1]:\n+                return request_list[1]\n+            else:\n+                raise ValueError\n+                # 400\n+        else:\n+            raise TypeError\n+            # 505\n+    else:\n+        raise NameError","path":"src/concurrent_server.py","position":57,"original_position":57,"commit_id":"d93678f967681a78e09f60142fd9fccd067871cc","original_commit_id":"d93678f967681a78e09f60142fd9fccd067871cc","user":{"login":"cewing","id":417109,"avatar_url":"https://avatars.githubusercontent.com/u/417109?v=3","gravatar_id":"","url":"https://api.github.com/users/cewing","html_url":"https://github.com/cewing","followers_url":"https://api.github.com/users/cewing/followers","following_url":"https://api.github.com/users/cewing/following{/other_user}","gists_url":"https://api.github.com/users/cewing/gists{/gist_id}","starred_url":"https://api.github.com/users/cewing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cewing/subscriptions","organizations_url":"https://api.github.com/users/cewing/orgs","repos_url":"https://api.github.com/users/cewing/repos","events_url":"https://api.github.com/users/cewing/events{/privacy}","received_events_url":"https://api.github.com/users/cewing/received_events","type":"User","site_admin":false},"body":"It might be a bit more pythonic to avoid nesting these if blocks:\r\n\r\n```python\r\nif request_list[0] != 'GET':\r\n    raise NameError\r\nif request_list[2] != 'HTTP/1.1':\r\n    raise TypeError\r\n...\r\n```","created_at":"2016-03-14T00:29:30Z","updated_at":"2016-03-14T00:29:30Z","html_url":"https://github.com/jeremytedwards/http-server/pull/5#discussion_r55946970","pull_request_url":"https://api.github.com/repos/jeremytedwards/http-server/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/jeremytedwards/http-server/pulls/comments/55946970"},"html":{"href":"https://github.com/jeremytedwards/http-server/pull/5#discussion_r55946970"},"pull_request":{"href":"https://api.github.com/repos/jeremytedwards/http-server/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/jeremytedwards/http-server/pulls/5","id":62619921,"html_url":"https://github.com/jeremytedwards/http-server/pull/5","diff_url":"https://github.com/jeremytedwards/http-server/pull/5.diff","patch_url":"https://github.com/jeremytedwards/http-server/pull/5.patch","issue_url":"https://api.github.com/repos/jeremytedwards/http-server/issues/5","number":5,"state":"open","locked":false,"title":"Concurrency","user":{"login":"paulsheridan","id":4859769,"avatar_url":"https://avatars.githubusercontent.com/u/4859769?v=3","gravatar_id":"","url":"https://api.github.com/users/paulsheridan","html_url":"https://github.com/paulsheridan","followers_url":"https://api.github.com/users/paulsheridan/followers","following_url":"https://api.github.com/users/paulsheridan/following{/other_user}","gists_url":"https://api.github.com/users/paulsheridan/gists{/gist_id}","starred_url":"https://api.github.com/users/paulsheridan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulsheridan/subscriptions","organizations_url":"https://api.github.com/users/paulsheridan/orgs","repos_url":"https://api.github.com/users/paulsheridan/repos","events_url":"https://api.github.com/users/paulsheridan/events{/privacy}","received_events_url":"https://api.github.com/users/paulsheridan/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-11T23:51:15Z","updated_at":"2016-03-14T00:29:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"38c9dc76c9a2737a5ab287585a2416aed42a18b7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jeremytedwards/http-server/pulls/5/commits","review_comments_url":"https://api.github.com/repos/jeremytedwards/http-server/pulls/5/comments","review_comment_url":"https://api.github.com/repos/jeremytedwards/http-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jeremytedwards/http-server/issues/5/comments","statuses_url":"https://api.github.com/repos/jeremytedwards/http-server/statuses/d93678f967681a78e09f60142fd9fccd067871cc","head":{"label":"jeremytedwards:concurrency","ref":"concurrency","sha":"d93678f967681a78e09f60142fd9fccd067871cc","user":{"login":"jeremytedwards","id":16873250,"avatar_url":"https://avatars.githubusercontent.com/u/16873250?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremytedwards","html_url":"https://github.com/jeremytedwards","followers_url":"https://api.github.com/users/jeremytedwards/followers","following_url":"https://api.github.com/users/jeremytedwards/following{/other_user}","gists_url":"https://api.github.com/users/jeremytedwards/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremytedwards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremytedwards/subscriptions","organizations_url":"https://api.github.com/users/jeremytedwards/orgs","repos_url":"https://api.github.com/users/jeremytedwards/repos","events_url":"https://api.github.com/users/jeremytedwards/events{/privacy}","received_events_url":"https://api.github.com/users/jeremytedwards/received_events","type":"User","site_admin":false},"repo":{"id":53373352,"name":"http-server","full_name":"jeremytedwards/http-server","owner":{"login":"jeremytedwards","id":16873250,"avatar_url":"https://avatars.githubusercontent.com/u/16873250?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremytedwards","html_url":"https://github.com/jeremytedwards","followers_url":"https://api.github.com/users/jeremytedwards/followers","following_url":"https://api.github.com/users/jeremytedwards/following{/other_user}","gists_url":"https://api.github.com/users/jeremytedwards/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremytedwards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremytedwards/subscriptions","organizations_url":"https://api.github.com/users/jeremytedwards/orgs","repos_url":"https://api.github.com/users/jeremytedwards/repos","events_url":"https://api.github.com/users/jeremytedwards/events{/privacy}","received_events_url":"https://api.github.com/users/jeremytedwards/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeremytedwards/http-server","description":"","fork":false,"url":"https://api.github.com/repos/jeremytedwards/http-server","forks_url":"https://api.github.com/repos/jeremytedwards/http-server/forks","keys_url":"https://api.github.com/repos/jeremytedwards/http-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeremytedwards/http-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeremytedwards/http-server/teams","hooks_url":"https://api.github.com/repos/jeremytedwards/http-server/hooks","issue_events_url":"https://api.github.com/repos/jeremytedwards/http-server/issues/events{/number}","events_url":"https://api.github.com/repos/jeremytedwards/http-server/events","assignees_url":"https://api.github.com/repos/jeremytedwards/http-server/assignees{/user}","branches_url":"https://api.github.com/repos/jeremytedwards/http-server/branches{/branch}","tags_url":"https://api.github.com/repos/jeremytedwards/http-server/tags","blobs_url":"https://api.github.com/repos/jeremytedwards/http-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeremytedwards/http-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeremytedwards/http-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeremytedwards/http-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeremytedwards/http-server/statuses/{sha}","languages_url":"https://api.github.com/repos/jeremytedwards/http-server/languages","stargazers_url":"https://api.github.com/repos/jeremytedwards/http-server/stargazers","contributors_url":"https://api.github.com/repos/jeremytedwards/http-server/contributors","subscribers_url":"https://api.github.com/repos/jeremytedwards/http-server/subscribers","subscription_url":"https://api.github.com/repos/jeremytedwards/http-server/subscription","commits_url":"https://api.github.com/repos/jeremytedwards/http-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeremytedwards/http-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeremytedwards/http-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeremytedwards/http-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeremytedwards/http-server/contents/{+path}","compare_url":"https://api.github.com/repos/jeremytedwards/http-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeremytedwards/http-server/merges","archive_url":"https://api.github.com/repos/jeremytedwards/http-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeremytedwards/http-server/downloads","issues_url":"https://api.github.com/repos/jeremytedwards/http-server/issues{/number}","pulls_url":"https://api.github.com/repos/jeremytedwards/http-server/pulls{/number}","milestones_url":"https://api.github.com/repos/jeremytedwards/http-server/milestones{/number}","notifications_url":"https://api.github.com/repos/jeremytedwards/http-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeremytedwards/http-server/labels{/name}","releases_url":"https://api.github.com/repos/jeremytedwards/http-server/releases{/id}","deployments_url":"https://api.github.com/repos/jeremytedwards/http-server/deployments","created_at":"2016-03-08T01:46:21Z","updated_at":"2016-03-09T05:04:49Z","pushed_at":"2016-03-12T00:23:59Z","git_url":"git://github.com/jeremytedwards/http-server.git","ssh_url":"git@github.com:jeremytedwards/http-server.git","clone_url":"https://github.com/jeremytedwards/http-server.git","svn_url":"https://github.com/jeremytedwards/http-server","homepage":null,"size":217,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"jeremytedwards:master","ref":"master","sha":"32ddae0b5bbab80b01807db88f358dfe745f6abe","user":{"login":"jeremytedwards","id":16873250,"avatar_url":"https://avatars.githubusercontent.com/u/16873250?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremytedwards","html_url":"https://github.com/jeremytedwards","followers_url":"https://api.github.com/users/jeremytedwards/followers","following_url":"https://api.github.com/users/jeremytedwards/following{/other_user}","gists_url":"https://api.github.com/users/jeremytedwards/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremytedwards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremytedwards/subscriptions","organizations_url":"https://api.github.com/users/jeremytedwards/orgs","repos_url":"https://api.github.com/users/jeremytedwards/repos","events_url":"https://api.github.com/users/jeremytedwards/events{/privacy}","received_events_url":"https://api.github.com/users/jeremytedwards/received_events","type":"User","site_admin":false},"repo":{"id":53373352,"name":"http-server","full_name":"jeremytedwards/http-server","owner":{"login":"jeremytedwards","id":16873250,"avatar_url":"https://avatars.githubusercontent.com/u/16873250?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremytedwards","html_url":"https://github.com/jeremytedwards","followers_url":"https://api.github.com/users/jeremytedwards/followers","following_url":"https://api.github.com/users/jeremytedwards/following{/other_user}","gists_url":"https://api.github.com/users/jeremytedwards/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremytedwards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremytedwards/subscriptions","organizations_url":"https://api.github.com/users/jeremytedwards/orgs","repos_url":"https://api.github.com/users/jeremytedwards/repos","events_url":"https://api.github.com/users/jeremytedwards/events{/privacy}","received_events_url":"https://api.github.com/users/jeremytedwards/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeremytedwards/http-server","description":"","fork":false,"url":"https://api.github.com/repos/jeremytedwards/http-server","forks_url":"https://api.github.com/repos/jeremytedwards/http-server/forks","keys_url":"https://api.github.com/repos/jeremytedwards/http-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeremytedwards/http-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeremytedwards/http-server/teams","hooks_url":"https://api.github.com/repos/jeremytedwards/http-server/hooks","issue_events_url":"https://api.github.com/repos/jeremytedwards/http-server/issues/events{/number}","events_url":"https://api.github.com/repos/jeremytedwards/http-server/events","assignees_url":"https://api.github.com/repos/jeremytedwards/http-server/assignees{/user}","branches_url":"https://api.github.com/repos/jeremytedwards/http-server/branches{/branch}","tags_url":"https://api.github.com/repos/jeremytedwards/http-server/tags","blobs_url":"https://api.github.com/repos/jeremytedwards/http-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeremytedwards/http-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeremytedwards/http-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeremytedwards/http-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeremytedwards/http-server/statuses/{sha}","languages_url":"https://api.github.com/repos/jeremytedwards/http-server/languages","stargazers_url":"https://api.github.com/repos/jeremytedwards/http-server/stargazers","contributors_url":"https://api.github.com/repos/jeremytedwards/http-server/contributors","subscribers_url":"https://api.github.com/repos/jeremytedwards/http-server/subscribers","subscription_url":"https://api.github.com/repos/jeremytedwards/http-server/subscription","commits_url":"https://api.github.com/repos/jeremytedwards/http-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeremytedwards/http-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeremytedwards/http-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeremytedwards/http-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeremytedwards/http-server/contents/{+path}","compare_url":"https://api.github.com/repos/jeremytedwards/http-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeremytedwards/http-server/merges","archive_url":"https://api.github.com/repos/jeremytedwards/http-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeremytedwards/http-server/downloads","issues_url":"https://api.github.com/repos/jeremytedwards/http-server/issues{/number}","pulls_url":"https://api.github.com/repos/jeremytedwards/http-server/pulls{/number}","milestones_url":"https://api.github.com/repos/jeremytedwards/http-server/milestones{/number}","notifications_url":"https://api.github.com/repos/jeremytedwards/http-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeremytedwards/http-server/labels{/name}","releases_url":"https://api.github.com/repos/jeremytedwards/http-server/releases{/id}","deployments_url":"https://api.github.com/repos/jeremytedwards/http-server/deployments","created_at":"2016-03-08T01:46:21Z","updated_at":"2016-03-09T05:04:49Z","pushed_at":"2016-03-12T00:23:59Z","git_url":"git://github.com/jeremytedwards/http-server.git","ssh_url":"git@github.com:jeremytedwards/http-server.git","clone_url":"https://github.com/jeremytedwards/http-server.git","svn_url":"https://github.com/jeremytedwards/http-server","homepage":null,"size":217,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jeremytedwards/http-server/pulls/5"},"html":{"href":"https://github.com/jeremytedwards/http-server/pull/5"},"issue":{"href":"https://api.github.com/repos/jeremytedwards/http-server/issues/5"},"comments":{"href":"https://api.github.com/repos/jeremytedwards/http-server/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/jeremytedwards/http-server/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/jeremytedwards/http-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jeremytedwards/http-server/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/jeremytedwards/http-server/statuses/d93678f967681a78e09f60142fd9fccd067871cc"}}}}