import io
from flask import request, send_file, make_response
from wechat_sdk import WechatBasic

from wechat_app import app, redis_store, wechat_conf

import wechat_message_handler

__author__ = 'guoyong'


@app.route('/wx', methods=['GET', 'POST'])
def handle_wechat_msg():

    app.logger.info('handle_wechat_msg')

    wechat = WechatBasic(conf=wechat_conf)

    handler_name = '%s_handler' % request.method.lower()
    dispatch_method = getattr(wechat_message_handler, handler_name)

    return dispatch_method(request, wechat)


@app.route('/apod.jpg', methods=['GET'])
def apod_image():

    key = '%s:image' % app.config['APOD_CACHE_KEY']
    apod_image = redis_store.get(key)

    if not apod_image:
        return 'APOD Not Found', 404

    response = make_response(apod_image)
    response.headers['Content-Type'] = 'image/jpeg'
    # response.headers['Content-Disposition'] = 'attachment; filename=apod.jpg'
    return response
    # return send_file(io.BytesIO(apod_image))


@app.route('/')
def index():
    return 'hello, world'

@@ -1,14 +1,4 @@
-import io%0A
 from
@@ -23,19 +23,8 @@
 est,
- send_file,
  mak
@@ -820,150 +820,23 @@
     
-# response.headers%5B'Content-Disposition'%5D = 'attachment; filename=apod.jpg'%0A    return response%0A    # return send_file(io.BytesIO(apod_image))
+return response
 %0A%0A%0A@

remove unused imports