forked from ScoDoc/installmgr
retreive real client IP
This commit is contained in:
parent
af888970f2
commit
f102cc22f1
@ -1,6 +1,6 @@
|
|||||||
# InstallMgr
|
# InstallMgr
|
||||||
|
|
||||||
Mini app Flask remplaçant les CGI Sciript de `scodoc.iutv`.
|
Mini-app Flask remplaçant les CGI scripts de `scodoc.iutv`.
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
|
@ -31,11 +31,13 @@ def upload_dump():
|
|||||||
Réception d'un fichier de dump uploadé
|
Réception d'un fichier de dump uploadé
|
||||||
"""
|
"""
|
||||||
log = open(LOG_FILENAME, "a")
|
log = open(LOG_FILENAME, "a")
|
||||||
|
log.write("hello\n")
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
fulltime = now.isoformat()
|
fulltime = now.isoformat()
|
||||||
# client addr:
|
# client addr:
|
||||||
remote_addr = request.environ.get("HTTP_X_Real_IP", request.remote_addr)
|
remote_addr = request.environ.get("HTTP_X_REAL_IP", request.remote_addr)
|
||||||
log.write("{} request from {}\n".format(fulltime, remote_addr))
|
|
||||||
|
log.write("{fulltime} request from {remote_addr}\n")
|
||||||
# Avec seulement alphanum et tiret:
|
# Avec seulement alphanum et tiret:
|
||||||
clean_deptname = re.sub(r"[^A-Za-z-]", "", request.form["dept_name"])
|
clean_deptname = re.sub(r"[^A-Za-z-]", "", request.form["dept_name"])
|
||||||
the_file = request.files["file"]
|
the_file = request.files["file"]
|
||||||
@ -105,6 +107,7 @@ def upload_dump():
|
|||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
log.write("exception while sending email !\n")
|
log.write("exception while sending email !\n")
|
||||||
|
log.close()
|
||||||
return ("", 204) # ok empty response
|
return ("", 204) # ok empty response
|
||||||
|
|
||||||
|
|
||||||
@ -161,3 +164,4 @@ def version():
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
f.close()
|
f.close()
|
||||||
|
return serial
|
||||||
|
@ -19,7 +19,7 @@ User=scodoc
|
|||||||
Group=scodoc
|
Group=scodoc
|
||||||
WorkingDirectory=/opt/installmgr
|
WorkingDirectory=/opt/installmgr
|
||||||
Environment=FLASK_RUN_PORT=5010
|
Environment=FLASK_RUN_PORT=5010
|
||||||
ExecStart=/opt/installmgr/venv/bin/gunicorn -b localhost:8010 -w 1 installmgr:app
|
ExecStart=/opt/installmgr/venv/bin/gunicorn -b localhost:8010 -w 2 installmgr:app
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
Loading…
Reference in New Issue
Block a user