Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我的路线正确吗?_Python_Flask_Pycharm - Fatal编程技术网

Python 我的路线正确吗?

Python 我的路线正确吗?,python,flask,pycharm,Python,Flask,Pycharm,你好,我试着复制PyPI只是为了学习一些基础知识。我从一个视频课程中学到这一点。现在它被引入了蓝图,我无法控制它。我总是得到错误404,很遗憾,我的课程不支持额外的帮助。有人能快点忽略我的代码,告诉我我做错了什么吗?那太好了,可以省下我晚上的时间 我在youtube上看到了几个不同的视频,并在这里寻找帖子,但我只找到了两个 app.py: import flask app = flask.Flask(__name__) def main(): register_blueprint

你好,我试着复制PyPI只是为了学习一些基础知识。我从一个视频课程中学到这一点。现在它被引入了蓝图,我无法控制它。我总是得到错误404,很遗憾,我的课程不支持额外的帮助。有人能快点忽略我的代码,告诉我我做错了什么吗?那太好了,可以省下我晚上的时间

我在youtube上看到了几个不同的视频,并在这里寻找帖子,但我只找到了两个

app.py:

import flask

app = flask.Flask(__name__)



def main():
    register_blueprints()
    app.run(debug=True)


def register_blueprints():
    from pypi_org.views import home_views
    from pypi_org.views import package_views

    app.register_blueprint(home_views.blueprint)
    app.register_blueprint(package_views.blueprint)


if __name__ == '__main__':
    main()
home_views.py:

import flask

from pypi_org.infrastructer.view_modifiers import response
import pypi_org.services.package_service as packages_service

blueprint = flask.Blueprint('home', __name__, template_folder='templates')




# #https://github.com/talkpython/data-driven-web-apps-with flask/tree/master/app/ch05_jinja_templates/final/pypi_org/infrastructure 
## I looked at his code but and I did it the same as he did. 


@blueprint.route('')
@response(template_file='home/index.html')
def index():
    test_packages = packages_service.get_latest_packages()
    return {'packages': test_packages}

    # return flask.render_template('home/index.html', packages = test_packages)
    ## Ansonsten ist dies der "normale" Weg.


@blueprint.route('/about')
@response(template_file='home/about.html')
def about():
    return {}
import flask


from pypi_org.infrastructer.view_modifiers import response
import pypi_org.services.package_service as packages_service

blueprint = flask.Blueprint('packages', __name__, template_folder='templates')


@blueprint.route('/package/<package_name>')
#@response(template_file='packages/details.html')
def package_details(package_name: str):
    return 'Package details for {}'.format(package_name)



包_views.py:

import flask

from pypi_org.infrastructer.view_modifiers import response
import pypi_org.services.package_service as packages_service

blueprint = flask.Blueprint('home', __name__, template_folder='templates')




# #https://github.com/talkpython/data-driven-web-apps-with flask/tree/master/app/ch05_jinja_templates/final/pypi_org/infrastructure 
## I looked at his code but and I did it the same as he did. 


@blueprint.route('')
@response(template_file='home/index.html')
def index():
    test_packages = packages_service.get_latest_packages()
    return {'packages': test_packages}

    # return flask.render_template('home/index.html', packages = test_packages)
    ## Ansonsten ist dies der "normale" Weg.


@blueprint.route('/about')
@response(template_file='home/about.html')
def about():
    return {}
import flask


from pypi_org.infrastructer.view_modifiers import response
import pypi_org.services.package_service as packages_service

blueprint = flask.Blueprint('packages', __name__, template_folder='templates')


@blueprint.route('/package/<package_name>')
#@response(template_file='packages/details.html')
def package_details(package_name: str):
    return 'Package details for {}'.format(package_name)



导入烧瓶
从pypi_org.infrastructer.view_修改器导入响应
将pypi_org.services.package_服务导入为packages_服务
blueprint=flask.blueprint('packages','name','template','folder='templates')
@blueprint.route(“/package/”)
#@响应(模板文件=“packages/details.html”)
def包详细信息(包名称:str):
返回{}的包详细信息。格式(包名称)

我真的需要一些帮助,为什么它不起作用。它让我发疯