check hostname for invalid characters

This commit is contained in:
Jordan Rodgers 2017-12-10 17:02:49 -05:00
parent 29873e2055
commit f3d69381c1
4 changed files with 29 additions and 11 deletions

9
app.py
View file

@ -46,8 +46,13 @@ def hostname(name):
starrs = connect_starrs(
app.config['STARRS_DB_NAME'], app.config['STARRS_DB_USER'],
app.config['STARRS_DB_HOST'], app.config['STARRS_DB_PASS'])
result = check_hostname(starrs, name)
return str(result)
valid, available = check_hostname(starrs, name)
if not valid:
return 'invalid'
if not available:
return 'taken'
else:
return 'ok'
@app.route("/vm/<string:vmid>")