def hello_world(): # url = "http://news-at.zhihu.com/api/4/news/latest" # data=urllib.request.urlopen(url).read() # z_data=data.decode('UTF-8') # items = json.loads(z_data) stories = ZhihuModel.objects() return render_template('home.html',stories=stories)
def detile(itemid): zhihus = ZhihuModel.objects() for zhihu in zhihus: if(zhihu.item_id==int(itemid)): item = zhihu break return render_template('detail.html',item=item)
import sys,urllib,os sys.path.append('D:\\PycharmProjects\\FlaskBlog') from model import ZhihuModel from htmlparse import MyHTMLParser localPath = '..\\static\\image\\content' def createFileWithFileName(localPathParam,fileName): totalPath=localPathParam+'\\'+fileName if not os.path.exists(totalPath): file=open(totalPath,'a+') file.close() return totalPath zhihus = ZhihuModel.objects() for zhihu in zhihus: downloadImg(zhihu)