def do_GET(self): """Get requests.""" q = urlparse(self.path) request = { "headers": dict(self.headers), "path": q.path, "queryStringParameters": dict(parse_qsl(q.query)), "httpMethod": self.command, } response = APP(request, None) self.send_response(int(response["statusCode"])) for r in response["headers"]: self.send_header(r, response["headers"][r]) self.end_headers() if isinstance(response["body"], str): self.wfile.write(bytes(response["body"], "utf-8")) else: self.wfile.write(response["body"])
def main(place, date=None, forecast=None): """ The main method takes the command line arguments and call the app.py to get the info of entered place """ if not date: date = (datetime.date.today()).strftime("%b %d").upper() if not forecast: forecast = "monthly" obj = APP(place, date, forecast) try: data = obj.run() if not data: return {} return data except: return {}
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from app import APP if __name__ == '__main__': application = APP() application.run()
from app import APP app = APP() app.start()