from flask import Flask
from flask import jsonify
from flask import request
import os
from flask import make_response


UPLOAD_FOLDER = 'static/images'
app = Flask(__name__)

app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

@app.route('/hello/', methods=['GET', 'POST'])
def welcome():
    return "Hello World!"

@app.route('/<int:number>/')
def incrementer(number):
    return "Incremented number is " + str(number+1)

@app.route('/<string:name>/')
def hello(name):
    return "Hello " + name

@app.route('/person/')
def hello_2():
    return jsonify({'name':'Jimit',
                    'address':'India'})


@app.route('/image', methods=['POST'])
def receive_face_detect():
    img = request.files['image_data']
    path = os.path.join(app.config['UPLOAD_FOLDER'], img.filename)

    img.save(path)
    data = {'path':path,'size': os.path.getsize(path)}
    resp = make_response(data, 200)

    resp.headers.set('Content-Type',
                     'application/octet-stream')
    return resp


def main():
    app.run()#host='192.168.1.55',port=8080
if __name__ == '__main__':
    main()

