Commit 7fa558f8d860929061d5ad5e33067ac1dd605c6d

Authored by Adabriand Furtado
1 parent 14a87983
Exists in master

Configuração do servidor para rodar no Apache.

contrib/apache/validador.conf.tmpl 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +<VirtualHost *:80>
  2 + ServerName localhost
  3 +
  4 + WSGIDaemonProcess validador user=user1 group=group1 threads=5
  5 + WSGIScriptAlias /validador-backend <path-to-project>/contrib/validador.wsgi
  6 +
  7 + <Directory <path-to-project>>
  8 + WSGIProcessGroup validador
  9 + WSGIApplicationGroup %{GLOBAL}
  10 + Order deny,allow
  11 + Allow from all
  12 + Require all granted
  13 + </Directory>
  14 +
  15 + Alias /validador <path-to-project>/view
  16 + <Directory <path-to-project>/view>
  17 + Order deny,allow
  18 + Allow from all
  19 + Require all granted
  20 + </Directory>
  21 +
  22 + Header set Access-Control-Allow-Origin "*"
  23 +
  24 + ServerAdmin webmaster@localhost
  25 +
  26 + ErrorLog ${APACHE_LOG_DIR}/error.log
  27 + CustomLog ${APACHE_LOG_DIR}/access.log combined
  28 +</VirtualHost>
... ...
contrib/validador.wsgi.tmpl 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +# Check the official documentation http://flask.pocoo.org/docs/deploying/mod_wsgi/
  2 +# Activate the virtual env (we assume that virtualenv is in the env folder)
  3 +activate_this = '<path-to-project>/env/bin/activate_this.py'
  4 +execfile(activate_this, dict(__file__=activate_this))
  5 +import logging, sys
  6 +sys.stdout = sys.stderr
  7 +logging.basicConfig(stream=sys.stderr)
  8 +sys.path.insert(0,'<path-to-project>')
  9 +
  10 +# Run the web-app
  11 +from main import app as application
... ...
main.py
... ... @@ -7,15 +7,8 @@ import os
7 7 import pyutil
8 8  
9 9 app = Flask(__name__)
10   -CORS(app)
11 10 controller = None
12 11  
13   -@app.route("/<path:path>")
14   -def send_static_files(path):
15   - root_dir = os.path.abspath(os.path.dirname(__file__))
16   - file_dir = os.path.join(root_dir, "view")
17   - return send_from_directory(file_dir, path)
18   -
19 12 @app.route("/update_project")
20 13 def update_project():
21 14 try:
... ... @@ -45,17 +38,34 @@ def read_settings(app):
45 38 config_path = os.path.join(os.path.dirname(here), 'settings_local.py')
46 39 if os.path.exists(config_path):
47 40 app.config.from_pyfile(config_path)
48   - app.config['HOST_ENDPOINT'] = "http://" + app.config['SERVER_HOST'] + ":" + str(app.config['SERVER_PORT'])
  41 +
  42 + if app.config['APACHE_HOST']:
  43 + app.config['HOST_ENDPOINT'] = "http://" + app.config['SERVER_HOST'] + app.config['APACHE_HOST_ENDPOINT']
  44 + app.config['HOST_STATIC_FILES_ENDPOINT'] = "http://" + app.config['SERVER_HOST'] + app.config['APACHE_STATIC_FILES_ENDPOINT']
  45 + else:
  46 + app.config['HOST_ENDPOINT'] = "http://" + app.config['SERVER_HOST'] + ":" + str(app.config['SERVER_PORT'])
  47 + app.config['HOST_STATIC_FILES_ENDPOINT'] = app.config['HOST_ENDPOINT']
49 48  
50 49 def setup_controller():
51 50 global controller
52 51 read_settings(app)
53 52 env = Environment(loader=PackageLoader('main', 'view'))
54 53 controller = Validador(app.config, env)
  54 +
  55 +def setup_static_files_service(app):
  56 + if not app.config['APACHE_HOST']:
  57 + CORS(app)
  58 + @app.route("/<path:path>")
  59 + def send_static_files(path):
  60 + root_dir = os.path.abspath(os.path.dirname(__file__))
  61 + file_dir = os.path.join(root_dir, "view")
  62 + return send_from_directory(file_dir, path)
55 63  
56 64 def run():
57   - setup_controller()
58 65 app.run(host=app.config['SERVER_HOST'], port=app.config['SERVER_PORT'])
  66 +
  67 +setup_controller()
  68 +setup_static_files_service(app)
59 69  
60 70 if __name__ == '__main__':
61 71 try:
... ...
settings_local.py.tmpl
1 1 # -*- coding: utf-8 -*-
2   -# Corretor Server Configuration
  2 +# Validador Server Configuration
3 3 SERVER_HOST = "localhost"
4 4 SERVER_PORT = 8001
5 5 AGREEMENT_NUMBER = 3
6 6  
  7 +# Apache Configuration
  8 +APACHE_HOST = False
  9 +APACHE_HOST_ENDPOINT = "/validador-backend"
  10 +APACHE_STATIC_FILES_ENDPOINT = "/validador"
  11 +
7 12 # PyBossa Configuration
8 13 PYBOSSA_APP_NAME = "Validador de Sinais"
9 14 PYBOSSA_APP_SHORT_NAME = "validador_sinais"
... ...
validador.py
... ... @@ -32,10 +32,11 @@ class Validador:
32 32  
33 33 def __update_project_info(self, project):
34 34 template = self.env.get_template('template.html')
35   - project.info['task_presenter'] = template.render(server=self.config['HOST_ENDPOINT'], app_shortname=self.config['PYBOSSA_APP_SHORT_NAME'])
  35 + project.info['task_presenter'] = template.render(server=self.config['HOST_STATIC_FILES_ENDPOINT'], server_backend=self.config['HOST_ENDPOINT'], app_shortname=self.config['PYBOSSA_APP_SHORT_NAME'])
36 36 project.info['thumbnail'] = self.config['HOST_ENDPOINT'] + "/img/thumbnail.png"
37 37 project.info['sched'] = "incremental"
38 38 project.allow_anonymous_contributors = False
  39 + #project.published = True
39 40 pbclient.update_project(project)
40 41  
41 42 def create_project(self):
... ...
view/assets/js/validador.js 100644 → 100755
... ... @@ -2,6 +2,7 @@
2 2  
3 3 var videos_url = "";
4 4 var base_url = "";
  5 + var server_backend_url = '';
5 6 var current_task_id = -1;
6 7  
7 8 function _disableFinishButton() {
... ... @@ -162,7 +163,7 @@
162 163 $
163 164 .ajax({
164 165 type : "POST",
165   - url : base_url + "/finish_task",
  166 + url : server_backend_url + "/finish_task",
166 167 data : {
167 168 "task_id" : task.id,
168 169 "project_id" : task.project_id,
... ... @@ -235,8 +236,9 @@
235 236 }
236 237  
237 238 // Public methods
238   - validador.run = function(serverhost, projectname) {
  239 + validador.run = function(serverhost, serverbackend, projectname) {
239 240 base_url = serverhost;
  241 + server_backend_url = serverbackend;
240 242 videos_url = base_url + "/videos/";
241 243 _run(projectname);
242 244 };
... ...
view/img/correct.png 100644 → 100755

4.98 KB | W: | H:

4.98 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
view/img/incorrect.png 100644 → 100755

4.88 KB | W: | H:

4.88 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
view/img/loading.gif 100644 → 100755

78 KB | W: | H:

78 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
view/img/thumbnail.png 100644 → 100755

34.6 KB | W: | H:

34.6 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
view/template.html
... ... @@ -99,5 +99,5 @@
99 99 </div>
100 100  
101 101 <script type="text/javascript">
102   - validador.run("{{ server }}", "{{ app_shortname }}");
  102 + validador.run("{{ server }}", "{{ server_backend }}", "{{ app_shortname }}");
103 103 </script>
... ...
view/videos/ENSINADO_AVATAR.webm 100644 → 100755
No preview for this file type
view/videos/ENSINADO_REF.webm 100644 → 100755
No preview for this file type
view/videos/ENTANTO_AVATAR.webm 100644 → 100755
No preview for this file type
view/videos/ENTANTO_REF.webm 100644 → 100755
No preview for this file type
view/videos/ENTENDIDO_AVATAR.webm 100644 → 100755
No preview for this file type
view/videos/ENTENDIDO_REF.webm 100644 → 100755
No preview for this file type