我有一个Flask/Angular应用程序,我用这个命令提供服务。Flask、Angular和mod_wsgi-express都是这个项目的必备组件。
$ mod_wsgi-express start-server run_apache_server.wsgi --rewrite-rules rewrite_psyche_data.confpython看起来像这样(psyche_data_master是git代码库,psyche_data是flask应用程序的run_apache_server.wsgi模块):
# run_apache_server.wsgi
import sys
#Expand Python classes path with your app's path
sys.path.insert(0, "/Users/Jakob/Desktop/dev_projects/psyche_data_master/psyche_data")
from psyche_data import app
#Initialize WSGI app object
application = app在这里,我尝试了一些基于帮助论坛的方法来修复404错误(这些错误是由使用这个HTML选项时的角度路由问题引起的,我必须使用这个选项)。
1)当rewrite_psyche_data.conf如下所示时:
Options FollowSymLinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /#/$1 [L]..。最后,我的页面看起来像原始的HTML,并且我看到控制台错误显示“意外令牌:<”,当我单击这些错误时,JS文件本身就充满了HTML。
->8
2)当rewrite_psyche_data.conf如下所示时:
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]...I在根URL (本地主机:8000)的索引页上得到一个404错误。当我运行它时,命令似乎没有失败:
$ mod_wsgi-express start-server run_apache_server.wsgi --rewrite-rules rewri_psyche_data.conf
Server URL : http://localhost:8000/
Server Root : /tmp/mod_wsgi-localhost:8000:503
Server Conf : /tmp/mod_wsgi-localhost:8000:503/httpd.conf
Error Log File : /tmp/mod_wsgi-localhost:8000:503/error_log (warn)
Rewrite Rules : /Users/Jakob/Desktop/dev_projects/psyche_data_master/rewrite_psyche_data.conf
Request Capacity : 5 (1 process * 5 threads)
Request Timeout : 60 (seconds)
Startup Timeout : 15 (seconds)
Queue Backlog : 100 (connections)
Queue Timeout : 45 (seconds)
Server Capacity : 20 (event/worker), 20 (prefork)
Server Backlog : 500 (connections)
Locale Setting : en_US.UTF-8...and错误日志文件中显示以下两行:
[Mon May 22 21:17:00.788635 2017] [mpm_event:notice] [pid 12005:tid 140735965213632] AH00489: Apache/2.4.23 (Unix) mod_wsgi/4.5.15 Python/2.7 configured -- resuming normal operations
[Mon May 22 21:17:00.789013 2017] [core:notice] [pid 12005:tid 140735965213632] AH00094: Command line: 'httpd (mod_wsgi-express) -f /tmp/mod_wsgi-localhost:8000:503/httpd.conf -D MOD_WSGI_MPM_ENABLE_EVENT_MODULE -D MOD_WSGI_MPM_EXISTS_EVENT_MODULE -D MOD_WSGI_MPM_EXISTS_WORKER_MODULE -D MOD_WSGI_MPM_EXISTS_PREFORK_MODULE -D FOREGROUND'->8
3)当我运行此应用程序时,应用程序可以工作,但每当我刷新Angular Routing生成的任何URL时,我都会收到404个错误:
$ mod_wsgi-express start-server run_apache_server.wsgi我应该像--include-file一样做--rewrite-rules以外的事情吗?
发布于 2017-05-23 13:16:57
我在烧瓶端做了一些挖掘,这样做似乎已经解决了这个问题:
# routing for basic pages (pass routing onto the Angular app)
@app.route('/')
@app.route('/about')
@app.route('/contact')
@app.route('/studies')
def basic_pages(**kwargs):
return make_response(open('psyche_data/templates/index.html').read())现在,当我加载名为"/about“的路由时,URL会发生变化,我可以刷新它,并且不会出现404错误。即使没有重写规则。
https://stackoverflow.com/questions/44125795
复制相似问题