Changeset 16458


Ignore:
Timestamp:
Aug 2, 2016, 12:41:33 PM (3 years ago)
Author:
dferreira
Message:

Start saving model on memory

Location:
internals/2016/aptoideimagesdetector/trunk/explicit_content_detector
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • internals/2016/aptoideimagesdetector/trunk/explicit_content_detector/API/views.py

    r16448 r16458  
    99from django.http import HttpResponse
    1010from django.shortcuts import redirect
     11from django.db.models.base import ModelBase
    1112from bs4 import BeautifulSoup
    1213from Explicit_detector import analyse_app
     14import threading
    1315import urllib2
    1416import json
     17
     18# Save the Illustration2Vec model on memory
     19# Not needed to load everytime that exists a request
     20class Model(ModelBase):
     21        _model = analyse_app.get_model()
    1522
    1623
    1724def index(request, app_id):
    1825        url = "http://webservices.aptoide.com/webservices/3/getApkInfo/id:"
    19         print "Getting the model..."
    20         illust2vec = analyse_app.get_model()
     26        illust2vec = Model._model
     27
    2128        try:
    2229                # Fetching the JSON content
     
    8390                status = 'Failed'
    8491                print "Error during parsing"
    85         response = json.dumps({'app_id': app_id, 'status': status,'is_mature_content': exp}, sort_keys=True)
     92        #response = json.dumps({'app_id': app_id, 'status': status,'is_mature_content': exp}, sort_keys=True)
    8693        #return HttpResponse(response)
     94
    8795        if exp:
    8896                return redirect('true', app_id=app_id)
     
    9098
    9199def true(request, app_id):
    92         return HttpResponse(str(app_id)+" have explicit content")
     100        return HttpResponse(json.dumps({'app_id': app_id, 'status': 'OK','mature_content': 'yes'}, sort_keys=True))
    93101
    94102def false(request, app_id):
    95         return HttpResponse(str(app_id)+" does not have explicit content")
     103        return HttpResponse(json.dumps({'app_id': app_id, 'status': 'OK','mature_content': 'no'}, sort_keys=True))
    96104
    97105def error(request, app_id):
    98         return HttpResponse("Error analysing "+str(app_id))
     106        return HttpResponse(json.dumps({'app_id': app_id, 'status': 'Failed','mature_content': '?'}, sort_keys=True))
  • internals/2016/aptoideimagesdetector/trunk/explicit_content_detector/explicit_content_detector/settings.py

    r16448 r16458  
    6969]
    7070
     71SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
    7172WSGI_APPLICATION = 'explicit_content_detector.wsgi.application'
    7273
Note: See TracChangeset for help on using the changeset viewer.