Files
@ f066d6e874db
Branch filter:
Location: light9/bin/homepageConfig - annotation
f066d6e874db
1.4 KiB
text/plain
2to3 with these fixers: all idioms set_literal
Ignore-this: cbd28518218c2f0ddce8c4f92d3b8b33
Ignore-this: cbd28518218c2f0ddce8c4f92d3b8b33
0d295af23c4b 0d295af23c4b 0d295af23c4b 0d295af23c4b 0d295af23c4b f066d6e874db f066d6e874db 0d295af23c4b 6fa4288da8a6 0d295af23c4b 0d295af23c4b 70f42f9d6e04 0d295af23c4b 70f42f9d6e04 15f296550447 15f296550447 15f296550447 f066d6e874db e703b3434dbd 7772cc48e016 cec677a84142 f066d6e874db 44558087d3f6 e703b3434dbd 70f42f9d6e04 70f42f9d6e04 70f42f9d6e04 70f42f9d6e04 70f42f9d6e04 0d295af23c4b 70f42f9d6e04 c8cffe82b537 70f42f9d6e04 f066d6e874db cec677a84142 7772cc48e016 cec677a84142 cec677a84142 cec677a84142 cec677a84142 cec677a84142 cec677a84142 cec677a84142 cec677a84142 cec677a84142 cec677a84142 f066d6e874db cec677a84142 cec677a84142 7772cc48e016 7772cc48e016 7772cc48e016 f066d6e874db | #!bin/python
from run_local import log
from rdflib import RDF, URIRef
from light9 import networking, showconfig
from light9.namespaces import L9
from urllib.parse import urlparse
from urllib.parse import splitport
from rdfdb.syncedgraph import SyncedGraph
from twisted.internet import reactor
graph = showconfig.getGraph()
netHome = graph.value(showconfig.showUri(), L9['networking'])
webServer = graph.value(netHome, L9['webServer'])
if not webServer:
raise ValueError('no %r :webServer' % netHome)
print("listen %s;" % splitport(urlparse(webServer).netloc)[1])
def location(path, server):
print("""
location /%(path)s/ {
# for websocket
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_pass %(server)s;
proxy_buffering off;
rewrite /[^/]+/(.*) /$1 break;
}""" % vars())
for role, server in sorted(graph.predicate_objects(netHome)):
if not server.startswith('http') or role == L9['webServer']:
continue
path = graph.value(role, L9['urlPath'])
if not path:
continue
server = server.rstrip('/')
location(path, server)
showPath = showconfig.showUri().split('/', 3)[-1]
print("""
location /%(path)s {
root %(root)s;
}""" % {
'path': showPath,
'root': showconfig.root()[:-len(showPath)]
})
|