-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
30 lines (22 loc) · 898 Bytes
/
Copy pathapp.py
File metadata and controls
30 lines (22 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from flask import Flask, request, Response
import json
from controllers import controller
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
@app.route('/send', methods=['POST'])
def send_email():
try:
book = request.files.get('data[file]')
title = request.args.get('title').replace('+', ' ')
author = request.args.get('author').replace('+', ' ')
kindle_email = request.args.get('email').replace('+', ' ')
return controller.send_email(book, title, author, kindle_email)
except:
data = {"message": "oh-oh something bad happened :("}
return Response(status=500, content_type='application/vnd.api+json', response=json.dumps(data))
@app.route('/', methods=('GET',))
def get_json():
return 'Use /send route to send books'
# TODO: create documentation and implement celery queue feat
app.run(host='0.0.0.0', port=5000)