mirror of
https://github.com/YunoHost/check-http.git
synced 2024-09-03 19:56:42 +02:00
[enh] progress
This commit is contained in:
parent
de00bfed5c
commit
28cf8f5ad3
1 changed files with 38 additions and 2 deletions
40
server.py
40
server.py
|
@ -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.")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue