22 lines
538 B
Python
22 lines
538 B
Python
from app import models
|
|
import os
|
|
from flask import request
|
|
|
|
import logging
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
def remote_ip():
|
|
if 'HTTP_X_FORWARDED_FOR' in request.environ:
|
|
xff_parts = request.environ.get('HTTP_X_FORWARDED_FOR').split(',')
|
|
return xff_parts[0]
|
|
else:
|
|
return request.environ.get('REMOTE_ADDR')
|
|
|
|
|
|
def webMode():
|
|
is_gunicorn = "gunicorn" in os.environ.get('SERVER_SOFTWARE', '')
|
|
is_werkzeug = os.environ.get('WERKZEUG_RUN_MAIN', False) == "true"
|
|
|
|
return is_gunicorn or is_werkzeug
|