Answer the question
In order to leave comments, you need to log in
How to update page content obtained by parsing another page in Flask?
There is some basic Flask code like this:
from flask import Flask
from test import text
app = Flask(__name__)
@app.route('/')
def main_page():
return text
if __name__ == '__main__':
app.run()
from bs4 import BeautifulSoup
import urllib.request
x = urllib.request.urlopen('http://www.example.com')
soup = BeautifulSoup(x)
text = str(soup.body.p)
Answer the question
In order to leave comments, you need to log in
Option one, not very good:
from flask import Flask
import test # именно так
app = Flask(__name__)
@app.route('/')
def main_page():
# постоянно актуальная информация, даже если переменная изменится в другом месте
return test.text
if __name__ == '__main__':
app.run()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question