简体   繁体   中英

404 Requested URL Not Found ( flask app on apache)

I deployed my flask web application on apache web server via mod_wsgi on windows server. I have used WSGIScriptAlias directive. When I try to run the url, I am able to view only the index/first page. When trying to hit post methods, I am unable to navigate to other url routes I have given in flask. It displays:- Not Found The requested URL /login was not found on this server.

I have also not configured virtual host in my httpd.conf file. I have used only the alias code as below:

<Directory "C:/Users/mypath/flask_phase2">
Require all granted
</Directory>
WSGIScriptAlias /flasktest "C:/Users/mypath/flask_phase2/landingpage.wsgi"

Alias "/static/" "C:/Users/mypath/flask_phase2/static/"
<Directory "C:/Users/mypath/flask_phase2/static/">
Require all granted
</Directory>

And my landingpage.wsgi code is as below:

import sys
sys.path.insert(0,"C:/Users/mypath/flask_phase2")
from landingpage import app as application

Can someone suggest me with a solution to this problem with this approach or is it necessary to configure virtualhost to make apache server to display all html,static pages as given in the post url method routes in the flask application?

Thanks. Appreciate your help.

You have hosted your app under /flasktest, so all its URLs are under that path. You can't go to /login, you would have to go to /flasktest/login.

If you don't want that (which you usually wouldn't), put your Flask app under the root path, /, instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM