Commit 1bca47c6295780a4b297770e001aeb9d08041db9
1 parent
761a3ec0
Exists in
master
Configuração do servidor para rodar no Apache.
Showing
37 changed files
with
74 additions
and
18 deletions
Show diff stats
@@ -0,0 +1,28 @@ | @@ -0,0 +1,28 @@ | ||
1 | +<VirtualHost *:80> | ||
2 | + ServerName localhost | ||
3 | + | ||
4 | + WSGIDaemonProcess corretor user=user1 group=group1 threads=5 | ||
5 | + WSGIScriptAlias /corretor-backend <path-to-project>/contrib/corretor.wsgi | ||
6 | + | ||
7 | + <Directory <path-to-project>> | ||
8 | + WSGIProcessGroup corretor | ||
9 | + WSGIApplicationGroup %{GLOBAL} | ||
10 | + Order deny,allow | ||
11 | + Allow from all | ||
12 | + Require all granted | ||
13 | + </Directory> | ||
14 | + | ||
15 | + Alias /corretor <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> |
@@ -0,0 +1,11 @@ | @@ -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 |
corretor.py
@@ -39,10 +39,11 @@ class Corretor: | @@ -39,10 +39,11 @@ class Corretor: | ||
39 | 39 | ||
40 | def __update_project_info(self, project): | 40 | def __update_project_info(self, project): |
41 | template = self.env.get_template('template.html') | 41 | template = self.env.get_template('template.html') |
42 | - project.info['task_presenter'] = template.render(server=self.config['HOST_ENDPOINT'], app_shortname=self.config['PYBOSSA_APP_SHORT_NAME']) | 42 | + 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']) |
43 | project.info['thumbnail'] = self.config['HOST_ENDPOINT'] + "/img/thumbnail.png" | 43 | project.info['thumbnail'] = self.config['HOST_ENDPOINT'] + "/img/thumbnail.png" |
44 | project.info['sched'] = "incremental" | 44 | project.info['sched'] = "incremental" |
45 | project.allow_anonymous_contributors = False | 45 | project.allow_anonymous_contributors = False |
46 | + #project.published = True | ||
46 | pbclient.update_project(project) | 47 | pbclient.update_project(project) |
47 | 48 | ||
48 | def __find_task(self, project_id, task_id): | 49 | def __find_task(self, project_id, task_id): |
main.py
@@ -7,15 +7,8 @@ import os | @@ -7,15 +7,8 @@ import os | ||
7 | import pyutil | 7 | import pyutil |
8 | 8 | ||
9 | app = Flask(__name__) | 9 | app = Flask(__name__) |
10 | -CORS(app) | ||
11 | controller = None | 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 | @app.route("/update_project") | 12 | @app.route("/update_project") |
20 | def update_project(): | 13 | def update_project(): |
21 | try: | 14 | try: |
@@ -61,18 +54,35 @@ def read_settings(app): | @@ -61,18 +54,35 @@ def read_settings(app): | ||
61 | config_path = os.path.join(os.path.dirname(here), 'settings_local.py') | 54 | config_path = os.path.join(os.path.dirname(here), 'settings_local.py') |
62 | if os.path.exists(config_path): | 55 | if os.path.exists(config_path): |
63 | app.config.from_pyfile(config_path) | 56 | app.config.from_pyfile(config_path) |
64 | - app.config['HOST_ENDPOINT'] = "http://" + app.config['SERVER_HOST'] + ":" + str(app.config['SERVER_PORT']) | 57 | + |
58 | + if app.config['APACHE_HOST']: | ||
59 | + app.config['HOST_ENDPOINT'] = "http://" + app.config['SERVER_HOST'] + app.config['APACHE_HOST_ENDPOINT'] | ||
60 | + app.config['HOST_STATIC_FILES_ENDPOINT'] = "http://" + app.config['SERVER_HOST'] + app.config['APACHE_STATIC_FILES_ENDPOINT'] | ||
61 | + else: | ||
62 | + app.config['HOST_ENDPOINT'] = "http://" + app.config['SERVER_HOST'] + ":" + str(app.config['SERVER_PORT']) | ||
63 | + app.config['HOST_STATIC_FILES_ENDPOINT'] = app.config['HOST_ENDPOINT'] | ||
65 | 64 | ||
66 | def setup_controller(): | 65 | def setup_controller(): |
67 | global controller | 66 | global controller |
68 | read_settings(app) | 67 | read_settings(app) |
69 | env = Environment(loader=PackageLoader('main', 'view')) | 68 | env = Environment(loader=PackageLoader('main', 'view')) |
70 | controller = Corretor(app.config, env) | 69 | controller = Corretor(app.config, env) |
70 | + | ||
71 | +def setup_static_files_service(app): | ||
72 | + if not app.config['APACHE_HOST']: | ||
73 | + CORS(app) | ||
74 | + @app.route("/<path:path>") | ||
75 | + def send_static_files(path): | ||
76 | + root_dir = os.path.abspath(os.path.dirname(__file__)) | ||
77 | + file_dir = os.path.join(root_dir, "view") | ||
78 | + return send_from_directory(file_dir, path) | ||
71 | 79 | ||
72 | def run(): | 80 | def run(): |
73 | - setup_controller() | ||
74 | app.run(host=app.config['SERVER_HOST'], port=app.config['SERVER_PORT']) | 81 | app.run(host=app.config['SERVER_HOST'], port=app.config['SERVER_PORT']) |
75 | 82 | ||
83 | +setup_controller() | ||
84 | +setup_static_files_service(app) | ||
85 | + | ||
76 | if __name__ == '__main__': | 86 | if __name__ == '__main__': |
77 | try: | 87 | try: |
78 | run() | 88 | run() |
settings_local.py.tmpl
@@ -5,6 +5,11 @@ SERVER_PORT = 8000 | @@ -5,6 +5,11 @@ SERVER_PORT = 8000 | ||
5 | AGREEMENT_NUMBER = 2 | 5 | AGREEMENT_NUMBER = 2 |
6 | UPLOAD_FOLDER = "<path-to-corretor>/view/uploads" | 6 | UPLOAD_FOLDER = "<path-to-corretor>/view/uploads" |
7 | 7 | ||
8 | +# Apache Configuration | ||
9 | +APACHE_HOST = False | ||
10 | +APACHE_HOST_ENDPOINT = "/corretor-backend" | ||
11 | +APACHE_STATIC_FILES_ENDPOINT = "/corretor" | ||
12 | + | ||
8 | # PyBossa Configuration | 13 | # PyBossa Configuration |
9 | PYBOSSA_APP_NAME = "Corretor de Sinais" | 14 | PYBOSSA_APP_NAME = "Corretor de Sinais" |
10 | PYBOSSA_APP_SHORT_NAME = "corretor_sinais" | 15 | PYBOSSA_APP_SHORT_NAME = "corretor_sinais" |
1 | (function(corretor, $, undefined) { | 1 | (function(corretor, $, undefined) { |
2 | 2 | ||
3 | var base_url = ""; | 3 | var base_url = ""; |
4 | + var server_backend_url = ""; | ||
4 | var videos_url = "/videos/"; | 5 | var videos_url = "/videos/"; |
5 | var uploads_url = "/uploads/"; | 6 | var uploads_url = "/uploads/"; |
6 | var upload_session_id = _getUploadSessionID(); | 7 | var upload_session_id = _getUploadSessionID(); |
@@ -91,14 +92,14 @@ | @@ -91,14 +92,14 @@ | ||
91 | $("#fix-button").hide(); | 92 | $("#fix-button").hide(); |
92 | } | 93 | } |
93 | 94 | ||
94 | - function setupButtons(task, deferred) { | 95 | + function _setupGUI(task, deferred) { |
95 | _disableFinishButton(); | 96 | _disableFinishButton(); |
96 | _resetUploadProgress(); | 97 | _resetUploadProgress(); |
97 | $("#upload-file-name").text("Escolha um arquivo"); | 98 | $("#upload-file-name").text("Escolha um arquivo"); |
98 | $("#file-upload").val(""); | 99 | $("#file-upload").val(""); |
99 | $("#file-upload").fileupload( | 100 | $("#file-upload").fileupload( |
100 | { | 101 | { |
101 | - url : base_url + "/upload", | 102 | + url : server_backend_url + "/upload", |
102 | formData : { | 103 | formData : { |
103 | "upload_session_id" : upload_session_id, | 104 | "upload_session_id" : upload_session_id, |
104 | 'sign_name' : task.info.sign_name | 105 | 'sign_name' : task.info.sign_name |
@@ -167,7 +168,7 @@ | @@ -167,7 +168,7 @@ | ||
167 | _enableLoading(); | 168 | _enableLoading(); |
168 | $.ajax({ | 169 | $.ajax({ |
169 | type : "POST", | 170 | type : "POST", |
170 | - url : base_url + "/render_video", | 171 | + url : server_backend_url + "/render_video", |
171 | data : { | 172 | data : { |
172 | "upload_session_id" : upload_session_id, | 173 | "upload_session_id" : upload_session_id, |
173 | "sign_name" : task.info.sign_name | 174 | "sign_name" : task.info.sign_name |
@@ -188,7 +189,7 @@ | @@ -188,7 +189,7 @@ | ||
188 | _enableLoading(); | 189 | _enableLoading(); |
189 | $.ajax({ | 190 | $.ajax({ |
190 | type : "POST", | 191 | type : "POST", |
191 | - url : base_url + "/finish_task", | 192 | + url : server_backend_url + "/finish_task", |
192 | data : { | 193 | data : { |
193 | "task_id" : task.id, | 194 | "task_id" : task.id, |
194 | "project_id" : task.project_id, | 195 | "project_id" : task.project_id, |
@@ -259,7 +260,7 @@ | @@ -259,7 +260,7 @@ | ||
259 | pybossa.presentTask(function(task, deferred) { | 260 | pybossa.presentTask(function(task, deferred) { |
260 | if (!$.isEmptyObject(task) && current_task_id != task.id) { | 261 | if (!$.isEmptyObject(task) && current_task_id != task.id) { |
261 | _loadTaskInfo(task, deferred); | 262 | _loadTaskInfo(task, deferred); |
262 | - setupButtons(task, deferred); | 263 | + _setupGUI(task, deferred); |
263 | $("#success").hide(); | 264 | $("#success").hide(); |
264 | $("#main-container").fadeIn(500); | 265 | $("#main-container").fadeIn(500); |
265 | } else { | 266 | } else { |
@@ -274,8 +275,9 @@ | @@ -274,8 +275,9 @@ | ||
274 | } | 275 | } |
275 | 276 | ||
276 | // Public methods | 277 | // Public methods |
277 | - corretor.run = function(serverhost, projectname) { | 278 | + corretor.run = function(serverhost, serverbackend, projectname) { |
278 | base_url = serverhost; | 279 | base_url = serverhost; |
280 | + server_backend_url = serverbackend; | ||
279 | videos_url = base_url + videos_url; | 281 | videos_url = base_url + videos_url; |
280 | uploads_url = base_url + uploads_url; | 282 | uploads_url = base_url + uploads_url; |
281 | _run(projectname); | 283 | _run(projectname); |
view/template.html
@@ -68,7 +68,6 @@ | @@ -68,7 +68,6 @@ | ||
68 | style="width: 22px; height: 22px"></img> | 68 | style="width: 22px; height: 22px"></img> |
69 | </a> | 69 | </a> |
70 | </div> | 70 | </div> |
71 | - <!-- <div class="row"></div> --> | ||
72 | <div id="upload-container" class="row"> | 71 | <div id="upload-container" class="row"> |
73 | <h6 id="upload-msg">ENVIAR ARQUIVO DE ANIMAÇÃO BLENDER | 72 | <h6 id="upload-msg">ENVIAR ARQUIVO DE ANIMAÇÃO BLENDER |
74 | CORRIGIDO:</h6> | 73 | CORRIGIDO:</h6> |
@@ -131,5 +130,5 @@ | @@ -131,5 +130,5 @@ | ||
131 | </div> | 130 | </div> |
132 | 131 | ||
133 | <script type="text/javascript"> | 132 | <script type="text/javascript"> |
134 | - corretor.run("{{ server }}", "{{ app_shortname }}"); | 133 | + corretor.run("{{ server }}", "{{ server_backend }}", "{{ app_shortname }}"); |
135 | </script> | 134 | </script> |
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type