#-*- coding: UTF-8 -*-
import sys 
sys.path.append("..")
import os
from flask import Flask, jsonify, request,json
from utils.crossdomain import crossdomain

app = Flask(__name__)

mockdir = os.path.dirname(os.path.realpath(__file__))
print mockdir

# ***
# *** 艺龙接口
# ***
# /payapi/rest
@app.route("/payapi/rest", methods=['GET'])
@crossdomain(origin='*')
def login():
    if request.method == 'GET':

    	method = request.args.get('method')
    	if method == 'hotel.list':
        	json_data = open(mockdir+'/../json/elong_hotel-list.json')
        elif method == 'hotel.detail':
        	json_data = open(mockdir+'/../json/elong_hotel-detail.json')
        else:
        	print 'Error: method does not exit!'
        return jsonify(json.load(json_data))


if __name__ == '__main__':
    # 内部监听使用127.0.0.1
    # app.run(debug=True, host="127.0.0.1", port=9000)

    # 公开IP监听
    app.run(debug=True, host="0.0.0.0", port=9001)



