第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用文件夾作為模塊在 pythonanywhere 上部署 Flask 應(yīng)用程序

如何使用文件夾作為模塊在 pythonanywhere 上部署 Flask 應(yīng)用程序

回首憶惘然 2021-09-11 15:19:08
目前我正在嘗試在 PythonAnywhere 上部署我的第一個 FLASK 應(yīng)用程序。我不確定這是否是正確的術(shù)語,但我有一個文件夾作為模塊,因為我似乎無法找到部署我的應(yīng)用程序的正確方法。我什至不確定從哪里開始解決這個問題。有什么建議嗎?我的init .py 代碼是:import osfrom flask import Flaskdef create_app(test_config=None):    # create and configure the app    app = Flask(__name__, instance_relative_config=True)    app.config.from_mapping(        SECRET_KEY='secret',        DATABASE=os.path.join(app.instance_path, 'LAMA.sqlite'),    )    if test_config is None:        # load the instance config, if it exists, when not testing        app.config.from_pyfile('config.py', silent=True)    else:        # load the test config if passed in        app.config.from_mapping(test_config)    # ensure the instance folder exists    try:        os.makedirs(app.instance_path)    except OSError:        pass    # database    from . import db    db.init_app(app)    # authentication blueprint    from . import auth    app.register_blueprint(auth.bp)    # blog blueprint - the main index    # from . import blog    # app.register_blueprint(blog.bp)    # app.add_url_rule('/', endpoint='index')    # book blueprint     from . import book    app.register_blueprint(book.bp)    app.add_url_rule('/', endpoint='index')    return app我還關(guān)注了 python 調(diào)試頁面,我已經(jīng)完成了以下操作:>>> import LAMA>>> print(LAMA)<module 'LAMA' from '/home/ivanv257/LAMA_MAIN/LAMA/__init__.py'>所以在我的 WSGI 配置文件的這個階段,我有:import syspath = '/home/ivanv257/LAMA_MAIN/LAMA/__init__.py'if path not in sys.path:    sys.path.append(path)from LAMA import app as application我還嘗試了許多其他組合,例如path = '/home/ivanv257/LAMA_MAIN/LAMA/'from init import app as applicationpath = '/home/ivanv257/LAMA_MAIN/'from init import app as applicationpath = '/home/ivanv257/LAMA_MAIN/'from LAMA import app as application我的源代碼路徑是: /home/ivanv257/LAMA_MAIN/LAMA ,雖然我也嘗試過不同的組合,例如 /home/ivanv257/LAMA_MAIN/
查看完整描述

2 回答

?
慕蓋茨4494581

TA貢獻(xiàn)1850條經(jīng)驗 獲得超11個贊

為了解決我的問題,我從 lama import create_app 更改了以下內(nèi)容(在一些幫助下):


import sys


path = '/home/ivanv257/LAMA_MAIN/LAMA'

if path not in sys.path:

    sys.path.append(path)


from lama import create_app


application = create_app()

我還必須從 . 只進(jìn)口


    import db

    db.init_app(app)


    # authentication blueprint

    import auth

    app.register_blueprint(auth.bp)


查看完整回答
反對 回復(fù) 2021-09-11
  • 2 回答
  • 0 關(guān)注
  • 324 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號