如何在枪支中设置文件夹和文件的路径?
这是我的烧瓶模块 main.py ,
import os
import Flask
import pandas as pd
app = Flask(__name__)
@app.route("/") # this route is working
def index():
return "this working"
@app.route("/data", methods=["POST"])
def get_data():
json = request.json
df = pd.DataFrame(json)
#here some other code that work on the data that are geting from folderspath as we have define below
if __name__=="__main__":
path=os.path.join(os.path.abspath(os.path.join('data')))
folder=os.path.join(path,'test')
app.run(debug=Flase,host="0.0.0.0")
如果我们只运行烧瓶服务器,则可以使用path Statment,但是如果我们设置为部署目的并将Gunicorn使用第一个路线工作。但是,当我们将请求发送到第二个路线时,它会在路径中提到缺少文件夹的错误。以下模块(wsgi.py)没有得到那些路径如何设置这些路径,它在wsgi.py
my gunicorn file wsgi.py.py
from main import app
if __name__=="__main__":
app.run()
我希望wsgi.py在应用程序之前执行这些路径。 run()我试图在app.run()和导入依赖性之前在WSGI中放入这些语句,但仍无法正常工作。
This my flask module main.py
import os
import Flask
import pandas as pd
app = Flask(__name__)
@app.route("/") # this route is working
def index():
return "this working"
@app.route("/data", methods=["POST"])
def get_data():
json = request.json
df = pd.DataFrame(json)
#here some other code that work on the data that are geting from folderspath as we have define below
if __name__=="__main__":
path=os.path.join(os.path.abspath(os.path.join('data')))
folder=os.path.join(path,'test')
app.run(debug=Flase,host="0.0.0.0")
if we just run the flask server it work and execute path statment but if we set for deployment purpose and using gunicorn the first route work. But when we send request to second route it give error of missing folder that are mention in paths. The below module (wsgi.py) is not getting those path how to set these path, that work in wsgi.py
My Gunicorn file wsgi.py
from main import app
if __name__=="__main__":
app.run()
I want wsgi.py to execute those path before app.run() I tried to put in those statement in wsgi before app.run() and imported dependences but still not working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试Gunicorn的-PythonPath论点:
You could try gunicorn's --pythonpath argument: