mirror of
https://github.com/ThomasGsp/HyperProxmox.git
synced 2025-02-15 04:32:15 +00:00
Delete tmp part
This commit is contained in:
parent
118ea63c1f
commit
38e5ba88ce
1 changed files with 12 additions and 35 deletions
|
@ -11,42 +11,19 @@ import random
|
||||||
import ast
|
import ast
|
||||||
|
|
||||||
|
|
||||||
""" --------- TMP PART --------- """
|
|
||||||
|
|
||||||
allowed = (
|
|
||||||
('jon','pass1'),
|
|
||||||
('tom','pass2')
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Index:
|
|
||||||
def GET(self):
|
|
||||||
if web.ctx.env.get('HTTP_AUTHORIZATION') is not None:
|
|
||||||
return 'This is the index page'
|
|
||||||
else:
|
|
||||||
raise web.seeother('/login')
|
|
||||||
|
|
||||||
class Login:
|
|
||||||
def GET(self):
|
|
||||||
auth = web.ctx.env.get('HTTP_AUTHORIZATION')
|
|
||||||
authreq = False
|
|
||||||
if auth is None:
|
|
||||||
authreq = True
|
|
||||||
else:
|
|
||||||
auth = re.sub('^Basic ','',auth)
|
|
||||||
username,password = base64.decodestring(auth).split(':')
|
|
||||||
if (username,password) in allowed:
|
|
||||||
raise web.seeother('/')
|
|
||||||
else:
|
|
||||||
authreq = True
|
|
||||||
if authreq:
|
|
||||||
web.header('WWW-Authenticate', 'Basic realm="Auth HyperProxmox API"')
|
|
||||||
web.ctx.status = '401 Unauthorized'
|
|
||||||
return
|
|
||||||
|
|
||||||
""" ------------------- """
|
|
||||||
|
|
||||||
""" CLASS MONGO CACHE """
|
""" CLASS MONGO CACHE """
|
||||||
|
class Purge:
|
||||||
|
def POST(self):
|
||||||
|
try:
|
||||||
|
result = core.managedata(json.loads(web.data().decode('utf-8')))
|
||||||
|
except BaseException as e:
|
||||||
|
result = {
|
||||||
|
"result": "ERROR",
|
||||||
|
"type": "PYTHON - API",
|
||||||
|
"value": "Invalid request: {0}".format(e)
|
||||||
|
}
|
||||||
|
return json.dumps(result)
|
||||||
|
|
||||||
class General_Search:
|
class General_Search:
|
||||||
def GET(self, query, id):
|
def GET(self, query, id):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue