Skip to content

Commit 8d5f76e

Browse files
committed
Python uwsgi works, but not with nginx
1 parent e7b2be7 commit 8d5f76e

File tree

1,919 files changed

+397286
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,919 files changed

+397286
-41
lines changed
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
#Run a test server
22
from app import app
33
app.run(host='0.0.0.0', port=8080, debug=True);
4-
5-

api-rest-python-deeplearning.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[uwsgi]
2+
module = wsgi:app
3+
4+
master = true
5+
processes = 5
6+
7+
socket = api-rest-python-deeplearning.sock
8+
chmod-socket = 660
9+
vacuum = true
10+
11+
die-on-term = true

app/__init__.py

491 Bytes
Binary file not shown.

app/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from flask.ext.sqlalchemy import SQLAlchemy
1+
from flask_sqlalchemy import SQLAlchemy
22
#from . import app
33

44

app/mod_photos/controllers.py

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
mod_photos = Blueprint('photos',__name__,url_prefix='/photos/v1.0')
1616

17-
1817
responses = FactoryResponse()
1918

2019
def allowed_file(filename):
@@ -24,17 +23,6 @@ def timestamp():
2423
import time
2524
return str(time.time()).split(".")[0]
2625

27-
def execute_tiny_cnn(filepath):
28-
#TODO add code tiny cpp examplei
29-
# ~/caffenet/deploy.prototxt ~/caffenet/bvlc_alexnet.caffemodel ~/caffenet/imagenet_mean.binaryproto ~/caffenet/synset_words.txt ~/caffenet/cat.jpg
30-
app.logger.debug("filepath="+str(filepath))
31-
output=check_output(["example_caffe_converter","deploy.prototxt","bvlc_alexnet.caffemodel","imagenet_mean.binaryproto","synset_words.txt",str(filepath)])
32-
#output=check_output(["echo", "caca1:resultado1\ncaca2:resultado2\ncaca3:resultado3\ncaca4:resultado4\ncaca5:resultado5"])
33-
app.logger.debug("output="+str(output))
34-
values = output.split("\n")[:-1][-5:]
35-
app.logger.debug("values="+str(values))
36-
return values
37-
3826
@mod_photos.route('/photos',methods=['POST'])
3927
def post_photos():
4028
app.logger.debug("Applying post photo...")
@@ -43,29 +31,23 @@ def post_photos():
4331
if request.method == 'POST':
4432
app.logger.debug("Applying post image")
4533
file = request.files['file']
46-
34+
4735
#TODO pending for testing!
4836
#if file and not allowed_file(file.filename):
4937
# return responses.new202()
50-
5138

5239
extension = os.path.splitext(file.filename)[1]
5340
identifier=timestamp()+str(uuid.uuid4())
5441
f_name=identifier + extension
5542
app.logger.debug("f_name="+f_name)
5643
app.logger.debug("identifier="+identifier)
5744
filepath=os.path.join(app.config['UPLOAD_FOLDER'], f_name)
58-
#First result
59-
60-
file.save(filepath)
61-
62-
values = execute_tiny_cnn(filepath)
63-
result = '\n'.join(values)
64-
65-
data_to_object ={'uuid':identifier, 'filepath': filepath, 'analysed':True, 'info':str(values)}
45+
#First result
46+
47+
data_to_object ={'uuid':identifier, 'filepath': filepath, 'analysed':False, 'info':str("empty")}
6648
new_photo = Photo.create(**data_to_object)
67-
68-
data = {'filename':f_name, 'info':str(values),'id': new_photo.id}
49+
50+
data = {'filename':f_name, 'id': new_photo.id}
6951
#TODO refactor to set up necessary methods to create responses
7052
#TODO is it necessary to return 200 command
7153
resp = None
@@ -99,4 +81,3 @@ def get_photos():
9981
'pagination':{'prev': prev,'next': next,'count':pagination.total}
10082
})
10183
return resp
102-

app/templates/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
document.getElementById("image1").src = oFREvent.target.result;
2525
};
2626
};
27-
27+
2828
</script>
29-
<!--
29+
<!--
3030
//TODO remove this web it is not working
3131
<script type="text/javascript" src="angular.min.js"></script>-->
3232

@@ -36,7 +36,7 @@
3636
<!--
3737
-->
3838
<!--<input type="file" ng-file-selected="onFileSelected($files)" file-model="myFile" ng-model="imageSrc" />
39-
-->
39+
-->
4040
<h3>{{responseid}}</h3>
4141
<input type="file" id="uploadImage1" onchange="UploadImage1();" file_model="myFile1">
4242
<br><br>

celerybeat-schedule

0 Bytes
Binary file not shown.

celeryconfig.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
CELERY_BROKER_URL="amqp://guest@localhost//"
55
CELERYBEAT_SCHEDULE = {
66
'every-day': {
7-
'task': 'tasks.newwinner',
8-
'schedule': timedelta(days=1),
7+
'task': 'tasks.analyse_document',
8+
'schedule': timedelta(seconds=5),
99
}
1010
}
1111
CELERY_TIMEZONE='UTC'

config.py

88 Bytes
Binary file not shown.

runp.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)