[enh] progress

This commit is contained in:
Laurent Peuch 2019-01-19 07:38:13 +01:00
parent de00bfed5c
commit 28cf8f5ad3

View file

@ -1,11 +1,47 @@
import json
from sanic import Sanic
from sanic.response import html
from sanic.response import html, json as json_response
from sanic.exceptions import InvalidUsage
app = Sanic()
@app.route("/check/", methods=["POST"])
async def check_http(request):
from ipdb import set_trace; set_trace()
ip = request.ip
try:
data = request.json
except InvalidUsage:
return json_response({
"status": "error",
"content": "InvalidUsage, body isn't proper json"
})
if "domain" not in data:
return json_response({"status": "error", "content": "request must specify a domain"})
domain = data["domain"]
# TODO DNS check
# [x] - get ip
# [x] - get request json
# [x] - in request json get domain target
# [ ] - check dns that domain == ip
# [ ] - if not, complain
# [ ] - if everything is ok, try to get with http
# [ ] - ADD TIMEOUT
# [ ] - try/catch, if everything is ok → response ok
# [ ] - otherwise reponse with exception
return json_response({"status": "ok"})
@app.route("/")
async def test(request):
async def main(request):
return html("You aren't really supposed to use this website using your browser.<br><br>It's a small server to check if a YunoHost instance can be reached by http before trying to instal a LE certificate.")