我编写了一个烧瓶休息API,在使用命令sudo python main.py
执行时可以正常工作。我想在apache中进行配置,以下是我所做的事情。
文件结构/home/user/project_name/src/restApi/
:
- __init__.py
- main.py
- app.py
- service.wsgi
这里是main.py
:
from app import app
@app.route('/api/v1/fileupload',methods=['POST'])
@auth.login_required
def upload_file():
// code
@auth.verify_password
def verify(username,password):
if not (username and password):
return False
return username == username and PASSWORD == password
if __name__ == "__main__":
app.run(host='0.0.0.0',port=80)
这是我的app.py
:
from flask import flask
app = flask(__name__)
//some config
这是我的service.wsgi
:
#!/usr/bin/python
import sys
sys.path.insert(3,"/home/user/project_name/src/restApi/")
from app import app as application
这里是/etc/httpd/config/httpd.config
<VirtualHost *:80>
ServerName 34.73.243.234
DocumentRoot /home/user/project_name/src/restApi/
WSGIScriptAlias /api/v1/fileupload /home/user/project_name/src/restApi/service.wsgi
<Directory /home/user/project_name/src/restApi/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
抱歉,如果我没有很好地解释。好吧,当我使用命令main.py
运行sudo python main.py
时,我能够上传文件。但是在配置了apache并点击了相同的URL之后,得到了与403禁止的响应You don't have permission to access /api/v1/fileupload on this server.
请帮帮我。我已经尝试了所有解决方案,但最终无法修复该错误。 谢谢