-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
42 lines (40 loc) · 1.01 KB
/
main.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
40
41
42
import json
import datetime
import random
import time
import numpy as np
from PIL import Image
from gevent.pywsgi import WSGIServer
import cv2
from flask import Flask, request, render_template
app = Flask(__name__)
app.config.from_object(__name__)
@app.route("/")
def index():
return "doutei"
@app.route("/posttest",methods=["GET","POST"])
def posttest():
if request.method=="POST":
#datakun=request.stream.read()
#img1 = cv2.imdecode(datakun, flags=cv2.IMREAD_GRAYSCALE)
#if(img1!=[]):
# print(img1)
img_pil = Image.open(request.stream)
img_numpy=np.asarray(img_pil)
img_numpy_bgr = cv2.cvtColor(img_numpy, cv2.COLOR_RGBA2BGR)
return "POST" + str(random.random())
else:
return "GET" + str(random.random())
def main():
print("hello work")
app.debug=True
host='0.0.0.0'
port=5454
host_port=(host,port)
server=WSGIServer(
host_port,
app
)
server.serve_forever()
if __name__ == '__main__':
main()