mirror of
https://github.com/markqvist/NomadNet.git
synced 2025-06-26 07:00:31 -04:00
Added page preprocessing
This commit is contained in:
parent
b8e67721b8
commit
a77f423362
3 changed files with 18 additions and 8 deletions
|
@ -2,6 +2,7 @@ import os
|
|||
import RNS
|
||||
import time
|
||||
import threading
|
||||
import subprocess
|
||||
import RNS.vendor.umsgpack as msgpack
|
||||
|
||||
class Node:
|
||||
|
@ -87,10 +88,14 @@ class Node:
|
|||
file_path = path.replace("/page", self.app.pagespath, 1)
|
||||
try:
|
||||
RNS.log("Serving page: "+file_path, RNS.LOG_VERBOSE)
|
||||
fh = open(file_path, "rb")
|
||||
response_data = fh.read()
|
||||
fh.close()
|
||||
return response_data
|
||||
if os.access(file_path, os.X_OK):
|
||||
generated = subprocess.run([file_path], stdout=subprocess.PIPE)
|
||||
return generated.stdout
|
||||
else:
|
||||
fh = open(file_path, "rb")
|
||||
response_data = fh.read()
|
||||
fh.close()
|
||||
return response_data
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Error occurred while handling request "+RNS.prettyhexrep(request_id)+" for: "+str(path), RNS.LOG_ERROR)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue