mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Some fixing
This commit is contained in:
parent
19dc86d32a
commit
239e0bb729
@ -24,6 +24,7 @@ lastsync = 0
|
|||||||
### symmetric keys are fine for now since we hopefully use HTTPS
|
### symmetric keys are fine for now since we hopefully use HTTPS
|
||||||
def loadAPIkeys():
|
def loadAPIkeys():
|
||||||
global clients
|
global clients
|
||||||
|
createTSV("clients/authenticated_machines.tsv")
|
||||||
clients = parseTSV("clients/authenticated_machines.tsv","string","string")
|
clients = parseTSV("clients/authenticated_machines.tsv","string","string")
|
||||||
|
|
||||||
def checkAPIkey(k):
|
def checkAPIkey(k):
|
||||||
|
12
server.py
12
server.py
@ -37,18 +37,20 @@ def database_get(pth):
|
|||||||
|
|
||||||
@post("/db/<pth:path>")
|
@post("/db/<pth:path>")
|
||||||
def database_post(pth):
|
def database_post(pth):
|
||||||
|
response.set_header("Access-Control-Allow-Origin","*")
|
||||||
try:
|
try:
|
||||||
proxyresponse = urllib.request.urlopen("http://localhost:" + str(DATABASE_PORT) + "/" + pth,request.body)
|
proxyresponse = urllib.request.urlopen("http://localhost:" + str(DATABASE_PORT) + "/" + pth,request.body)
|
||||||
contents = proxyresponse.read()
|
contents = proxyresponse.read()
|
||||||
response.status = proxyresponse.getcode()
|
response.status = proxyresponse.getcode()
|
||||||
|
response.content_type = "application/json"
|
||||||
|
return contents
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
contents = ""
|
|
||||||
response.status = e.code
|
response.status = e.code
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
response.content_type = "application/json"
|
|
||||||
response.set_header("Access-Control-Allow-Origin","*")
|
return
|
||||||
return contents
|
|
||||||
|
|
||||||
@route("/exit")
|
@route("/exit")
|
||||||
def shutdown():
|
def shutdown():
|
||||||
|
@ -50,3 +50,9 @@ def parseAllTSV(path,*args):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def createTSV(filename):
|
||||||
|
import os
|
||||||
|
|
||||||
|
if not os.path.exists(filename):
|
||||||
|
open(filename,"w").close()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user