簡體   English   中英

Python Flask,在更改 app.py Web 服務器未連接

[英]Python Flask, at change app.py Web server not connect

Some client (person) asked me to put jquery on a flask webserver in a Raspberry, honestly the folders of the web app are extrange, I asumme the flask is run automatically as a service each time the Raspberry switch on, the folder tree include the目錄和文件:

web 
|-WebDev
|  |-templates
|  |   |-index.html
|  |   |-main.html
|  |-static
|  |-__init__.py
|  |-__init__.pyc
|  |-app.py
|  |-app.pyc   
|-run.py

In tutorials I never see this type of flask web structure, I only know that in the app.py is the code that manage the request that index.html and main.html do.

The web site worked well, but I made changes on app.py for manage the ajax request for jquery and the enterely web page stop functioning, the web browser send the message that cannot connect with the site. 好吧,我測試把app.py的舊代碼再次復制同一個文件,但是web頁面發送同樣的問題,我不知道發生了什么,也許pyc文件是罪魁禍首?,舊的pyc文件是在編譯新的 app.py 時替換。 flask 服務正在運行,但瀏覽器中的頁面未連接。 如何解決這個問題?,樹的每個文件做什么?,我真的不知道客戶端做什么。

運行.py

from WebDev.app import service

if __name__ == '__main__':
    service.run(host='0.0.0.0', port=80, debug=True)

初始化.py

from flask import Flask
from flask_redis import FlaskRedis

service = Flask(__name__)

service.secret_key = 'any random string'

REDIS_URL = "redis://localhost:6379/0"

redis_store = FlaskRedis(service)

應用程序.py

from flask import render_template, request, redirect, url_for, session
from subprocess import call
from hashlib import sha256
from . import service, redis_store
import re
import subprocess

#do stuff for each request

問題不是 app.py 代碼,可能是更改我錯過的應用程序代碼時的一些程序

使用舊代碼再次工作,只需關閉 Raspberry 並保持至少幾分鍾,然后再次打開。 也許一些 sockets 或其他東西被阻塞或保持掛起,我不知道,但是在 app.py 執行失敗后使用這種方法,這是 flask Z2567A5EC9705EB7AC2C984033E0618D 頁面再次工作的唯一方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM