1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Some fixing

This commit is contained in:
Krateng 2018-11-30 16:01:32 +01:00
parent 19dc86d32a
commit 239e0bb729
3 changed files with 14 additions and 5 deletions

View File

@ -24,6 +24,7 @@ lastsync = 0
### symmetric keys are fine for now since we hopefully use HTTPS
def loadAPIkeys():
global clients
createTSV("clients/authenticated_machines.tsv")
clients = parseTSV("clients/authenticated_machines.tsv","string","string")
def checkAPIkey(k):

View File

@ -37,18 +37,20 @@ def database_get(pth):
@post("/db/<pth:path>")
def database_post(pth):
response.set_header("Access-Control-Allow-Origin","*")
try:
proxyresponse = urllib.request.urlopen("http://localhost:" + str(DATABASE_PORT) + "/" + pth,request.body)
contents = proxyresponse.read()
response.status = proxyresponse.getcode()
except HTTPError as e:
contents = ""
response.status = e.code
response.content_type = "application/json"
response.set_header("Access-Control-Allow-Origin","*")
return contents
except HTTPError as e:
response.status = e.code
return
return
@route("/exit")
def shutdown():

View File

@ -50,3 +50,9 @@ def parseAllTSV(path,*args):
return result
def createTSV(filename):
import os
if not os.path.exists(filename):
open(filename,"w").close()