forked from indymedia/epicyon
GET individual posts
parent
87fefd539b
commit
37568d5ed8
28
daemon.py
28
daemon.py
|
@ -8,6 +8,7 @@ __status__ = "Production"
|
||||||
|
|
||||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||||
#import socketserver
|
#import socketserver
|
||||||
|
import commentjson
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
@ -198,6 +199,33 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if self._webfinger():
|
if self._webfinger():
|
||||||
self.server.GETbusy=False
|
self.server.GETbusy=False
|
||||||
return
|
return
|
||||||
|
# get an individual post
|
||||||
|
if '/statuses/' in self.path and '/users/' in self.path:
|
||||||
|
namedStatus=self.path.split('/users/')[1]
|
||||||
|
if '/' in namedStatus:
|
||||||
|
postSections=namedStatus.split('/')
|
||||||
|
if len(postSections)>=2:
|
||||||
|
nickname=postSections[0]
|
||||||
|
statusNumber=postSections[2]
|
||||||
|
if len(statusNumber)>10:
|
||||||
|
domainFull=self.server.domain
|
||||||
|
if self.server.port!=80 and self.server.port!=443:
|
||||||
|
domainFull=self.server.domain+':'+str(self.server.port)
|
||||||
|
postFilename= \
|
||||||
|
self.server.baseDir+'/accounts/'+nickname+'@'+self.server.domain+'/outbox/'+ \
|
||||||
|
self.server.httpPrefix+':##'+domainFull+'#users#'+nickname+'#statuses#'+statusNumber+'.json'
|
||||||
|
if os.path.isfile(postFilename):
|
||||||
|
postJson={}
|
||||||
|
with open(postFilename, 'r') as fp:
|
||||||
|
postJson=commentjson.load(fp)
|
||||||
|
self._set_headers('application/json')
|
||||||
|
self.wfile.write(json.dumps(postJson).encode('utf-8'))
|
||||||
|
self.server.GETbusy=False
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
self._404()
|
||||||
|
self.server.GETbusy=False
|
||||||
|
return
|
||||||
# get the inbox for a given person
|
# get the inbox for a given person
|
||||||
if self.path.endswith('/inbox'):
|
if self.path.endswith('/inbox'):
|
||||||
if '/users/' in self.path:
|
if '/users/' in self.path:
|
||||||
|
|
Loading…
Reference in New Issue