-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.py
39 lines (30 loc) · 968 Bytes
/
app.py
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
31
32
33
34
35
36
37
38
39
from flask import Flask, render_template, request, jsonify
import sys
from server.action import action
import os
app = Flask(__name__)
@app.route("/home")
def home():
return render_template("home.html")
@app.route("/convert", methods=['POST'])
def convert():
file = request.files['image'].read()
resp = action(file)
#resp = "hello"
return resp
@app.route("/test", methods=['POST', 'GET'])
def test():
print("Success")
return jsonify({'status': 'success'})
@app.route("/")
def index():
return render_template("index.html")
@app.after_request
def after_request(response):
print("log: setting cors" , file = sys.stderr)
response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
return response
if __name__ == "__main__":
app.run(debug=True)