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
|
||||
def loadAPIkeys():
|
||||
global clients
|
||||
createTSV("clients/authenticated_machines.tsv")
|
||||
clients = parseTSV("clients/authenticated_machines.tsv","string","string")
|
||||
|
||||
def checkAPIkey(k):
|
||||
|
12
server.py
12
server.py
@ -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()
|
||||
response.content_type = "application/json"
|
||||
return contents
|
||||
except HTTPError as e:
|
||||
contents = ""
|
||||
response.status = e.code
|
||||
return
|
||||
|
||||
|
||||
response.content_type = "application/json"
|
||||
response.set_header("Access-Control-Allow-Origin","*")
|
||||
return contents
|
||||
|
||||
|
||||
return
|
||||
|
||||
@route("/exit")
|
||||
def shutdown():
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user