From 68637bd71b117b5f7b837077e5930f08a268271d Mon Sep 17 00:00:00 2001 From: Kyrylo Romanenko Date: Sat, 23 Apr 2016 00:38:14 +0300 Subject: [PATCH 1/2] Remove unused imports --- bin/srv.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/bin/srv.py b/bin/srv.py index 809b3a5..c54d2a3 100644 --- a/bin/srv.py +++ b/bin/srv.py @@ -1,22 +1,17 @@ -import sys import logging import os import re import requests import socket -import subprocess import time -import traceback import geoip2.database from geopy.geocoders import Nominatim import jinja2 -import gevent from gevent.wsgi import WSGIServer -from gevent.queue import Queue from gevent.monkey import patch_all -from gevent.subprocess import Popen, PIPE, STDOUT +from gevent.subprocess import Popen, PIPE patch_all() from flask import Flask, request, render_template, send_from_directory From d8750b4e75f30f4508cdc9bd149d74297b89c7f9 Mon Sep 17 00:00:00 2001 From: Kyrylo Romanenko Date: Sat, 23 Apr 2016 00:53:21 +0300 Subject: [PATCH 2/2] Minor code style fix Fix indentation and typo. --- bin/srv.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/srv.py b/bin/srv.py index c54d2a3..6d349c5 100644 --- a/bin/srv.py +++ b/bin/srv.py @@ -233,11 +233,11 @@ def wttr(location = None): orig_location = location if request.headers.getlist("X-Forwarded-For"): - ip = request.headers.getlist("X-Forwarded-For")[0] - if ip.startswith('::ffff:'): - ip = ip[7:] + ip = request.headers.getlist("X-Forwarded-For")[0] + if ip.startswith('::ffff:'): + ip = ip[7:] else: - ip = request.remote_addr + ip = request.remote_addr try: if location is None: @@ -252,7 +252,7 @@ def wttr(location = None): log("%s %s %s %s" % (ip, user_agent, orig_location, location)) return get_wetter( location, ip, html=html_output ) except Exception, e: - logging.error("Exception has occured", exc_info=1) + logging.error("Exception has occurred", exc_info=1) return str(e).rstrip()+"\n" server = WSGIServer(("", 8002), app)