La til autentikasjon i apien
This commit is contained in:
parent
6055f7f4ee
commit
8d472bdb9c
@ -1,18 +1,21 @@
|
||||
from flask import Flask, request, jsonify
|
||||
from PIL import Image
|
||||
import datetime
|
||||
import config
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/post_img", methods=["POST"])
|
||||
def process_image():
|
||||
if request.headers.get('Authorization') == 'Basic ' + config.api['key']:
|
||||
file = request.files['image']
|
||||
# Read the image via file.stream
|
||||
img = Image.open(file.stream)
|
||||
img = img.rotate(90, expand=True)
|
||||
time = str(datetime.datetime.now().isoformat(timespec='minutes'))
|
||||
img.save("./images/"+time+".png")
|
||||
img.save("./images/"+time+".jpg")
|
||||
|
||||
return jsonify({'msg': 'success'})
|
||||
|
||||
|
||||
else:
|
||||
return jsonify({'msg': 'auth_fail'})
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True)
|
||||
|
Loading…
Reference in New Issue
Block a user