Små endringer
This commit is contained in:
parent
5212aa9837
commit
6055f7f4ee
18
api.py
18
api.py
@ -1,18 +0,0 @@
|
|||||||
from flask import Flask, request, jsonify
|
|
||||||
from PIL import Image
|
|
||||||
import datetime
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
@app.route("/post_img", methods=["POST"])
|
|
||||||
def process_image():
|
|
||||||
file = request.files['image']
|
|
||||||
# Read the image via file.stream
|
|
||||||
img = Image.open(file.stream)
|
|
||||||
time = str(datetime.datetime.now().isoformat(timespec='minutes'))
|
|
||||||
img.save("./images/"+time+".png")
|
|
||||||
|
|
||||||
return jsonify({'msg': 'success'})
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
app.run(debug=True)
|
|
@ -1,8 +1,8 @@
|
|||||||
from flask import Flask, request, jsonify
|
from flask import Flask, request, jsonify
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
url = 'http://127.0.0.1:5000/post_img'
|
url = 'http://10.10.40.2:5000/post_img'
|
||||||
my_img = {'image': open('/home/trygve/Pictures/boiled.png', 'rb')}
|
my_img = {'image': open('test.png', 'rb')}
|
||||||
r = requests.post(url, files=my_img)
|
r = requests.post(url, files=my_img)
|
||||||
|
|
||||||
# convert server response into JSON format.
|
# convert server response into JSON format.
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
from flask import Flask, request, jsonify
|
|
||||||
import requests
|
|
||||||
|
|
||||||
url = 'http://127.0.0.1:5000/post_img'
|
|
||||||
my_img = {'image': open('/home/trygve/Pictures/boiled.png', 'rb')}
|
|
||||||
r = requests.post(url, files=my_img)
|
|
||||||
|
|
||||||
# convert server response into JSON format.
|
|
||||||
print(r.json())
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user