from flask import Flask, flash, render_template, session, request, redirect, url_for, jsonify from flask import current_app as app from admin.websiteinfo import * from admin.menuinfo import * from admin.researcharea import * from admin.teacherInfo import * from admin.studentinfo import * from admin.researchtopic import * from admin.knowledgetopictype import * from admin.knowledgetopic import * from admin.knowledgenote import * from admin.patentinfo import * from admin.paperinfo import * from admin.researchtopic import * from admin.sponsorinfo import * from flask_markdown_to_html import flask_markdown_to_html md = flask_markdown_to_html(app) # -------------前台 ------------------- # @app.route('/') # def up(): # return render_template('admin/uploadimage.html') @app.route('/') def index (): menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() researchtopic = loadResearchTopic_Top6() paperlist = loadPaperList_Top6() sp = loadSponsorList() return render_template('web/index.html', researchtopic=researchtopic, paperlist=paperlist, sponsorinfo=sp, menuinfo=menuinfo, webinfo=webinfo) # 教师/学生列表页 @app.route('/people') def loadpeoplelist (): teacherlist = loadAllTeacher_Show() studentlist = loadAllStudent_Show() menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() return render_template('web/f_peoplelist.html', teacherlist=teacherlist, studentlist=studentlist, menuinfo=menuinfo, webinfo=webinfo) # 教师内容页 @app.route('/teacherinfo/', methods=['POST', 'GET']) def loadteacherinfo (tid): teacherinfo = loadTeacherInfoByID_Show(tid) if (len(teacherinfo) > 0): teacherinfo = teacherinfo[0] menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() return render_template('web/f_teacherinfo.html', teacherinfo=teacherinfo, menuinfo=menuinfo, webinfo=webinfo) else: flash('成员信息不存在,请重新选择') return redirect(url_for('people')) # 学生内容页 @app.route('/studentinfo/', methods=['POST', 'GET']) def loadstudentinfo (sid): studentinfo = loadStudentByID_Show(sid) if (len(studentinfo) > 0): studentinfo = studentinfo menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() return render_template('web/f_studentinfo.html', studentinfo=studentinfo, menuinfo=menuinfo, webinfo=webinfo) else: flash('成员信息不存在,请重新选择') return redirect(url_for('people')) # 项目列表页 @app.route('/projects', methods=['POST', 'GET']) def loadallprojectlist (): researcharealist = loadAllResearchArea() researchtopiclist = loadAllResearchTopic_ForWeb() menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() return render_template('web/f_projectlist.html', researcharealist=researcharealist, researchtopiclist=researchtopiclist, menuinfo=menuinfo, webinfo=webinfo) # 项目列表页 @app.route('/project/', methods=['POST', 'GET']) def loadprojectlist (protid): projTypeList = loadAllResearchArea(protid) projInfoList = loadProjectInfoByPTID(protid) menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() if len(projTypeList) > 0: projType = projTypeList[0] else: projType = None return render_template('web/f_projectlist.html', projType=projType, projInfoList=projInfoList, menuinfo=menuinfo, webinfo=webinfo) # 项目内容页 @app.route('/projectinfo/', methods=['POST', 'GET']) def loadprojectinfo (proid): results_projinfo = loadResearchTopicByID_ForWeb(proid) if (len(results_projinfo) > 0): projinfo = results_projinfo menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() return render_template('web/f_projectinfo.html', projinfo=projinfo, menuinfo=menuinfo, webinfo=webinfo) else: flash('项目信息不存在,请重新选择') return redirect(url_for('project/1')) # 成果列表 @app.route('/publications', methods=['POST', 'GET']) def publications (): menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() ralist = loadAllResearchArea_Show() rtlist = loadAllResearchTopic_Show() paperlist = loadAllPaperInfo_Show() return render_template('web/f_publicationlist.html', ralist=ralist, paperlist=paperlist, menuinfo=menuinfo, webinfo=webinfo) # 成果内容 @app.route('/pubinfo/', methods=['POST', 'GET']) def pubinfo (pid): menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() results = loadPaperwithRTNamebyID(pid) return render_template('web/f_publicationinfo.html', paperinfo=results, menuinfo=menuinfo, webinfo=webinfo) # 知识库页面 @app.route('/resnotes', methods=['POST', 'GET']) def loadkonwtype_resnotes (): menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() knowledgetopictype = loadAllKnowledgeTopicType_ForeWeb("ResNotes") knowlegetopics = loadAllKnowledgeTopicWithKTTName_Show() return render_template('web/f_notestype.html', knowledgetopictype=knowledgetopictype, knowlegetopics=knowlegetopics, menuinfo=menuinfo, webinfo=webinfo) # 知识库页面 @app.route('/knoledge', methods=['POST', 'GET']) def loadkonwtype_knowledge (): menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() knowledgetopictype = loadAllKnowledgeTopicType_ForeWeb("Knoledge") knowlegetopics = loadAllKnowledgeTopicWithKTTName_Show() return render_template('web/f_knowtype.html', knowledgetopictype=knowledgetopictype, knowlegetopics=knowlegetopics, menuinfo=menuinfo, webinfo=webinfo) # 知识专题页面,包含多个笔记 @app.route('/knowlist/', methods=['POST', 'GET']) def konwlist (ktid): menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() KTName = getKTNameByKTID(ktid) notelist = loadKnowledgeNoteByKTID(ktid) if len(notelist) > 0: if notelist[0][1] ==10: return render_template('web/f_knowlist2.html', KTName=KTName, notelist=notelist, menuinfo=menuinfo, webinfo=webinfo) else: return render_template('web/f_knowlist.html', KTName=KTName, notelist=notelist, menuinfo=menuinfo, webinfo=webinfo) else: flash('知识专题不存在,请重新选择') return redirect(url_for('/knoledge')) # 知识专题页面,包含多个笔记 @app.route('/noteslist/', methods=['POST', 'GET']) def noteslist (ktid): menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() KTName = getKTNameByKTID(ktid) notelist = loadKnowledgeNoteByKTID(ktid) if len(notelist) > 0: if notelist[0][1] ==10: return render_template('web/f_noteslist2.html', KTName=KTName, notelist=notelist, menuinfo=menuinfo, webinfo=webinfo) else: return render_template('web/f_noteslist.html', KTName=KTName, notelist=notelist, menuinfo=menuinfo, webinfo=webinfo) else: flash('知识专题不存在,请重新选择') return redirect(url_for('/resnotes')) # 笔记具体内容 @app.route('/knowinfo/', methods=['POST', 'GET']) def knowinfo (knid): menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() noteinfo = loadKnowledgeNoteByKNID_Web(knid) if len(noteinfo) > 0: ktid = noteinfo[1] notelist = loadKnowledgeNoteByKTID(ktid) return render_template('web/f_knowinfo.html', notelist=notelist, noteinfo=noteinfo, menuinfo=menuinfo, webinfo=webinfo) else: flash('知识库笔记不存在,请重新选择') return redirect(url_for('/knoledge')) # 笔记具体内容 @app.route('/noteinfo/', methods=['POST', 'GET']) def noteinfo (knid): menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() noteinfo = loadKnowledgeNoteByKNID_Web(knid) if len(noteinfo) > 0: ktid = noteinfo[1] notelist = loadKnowledgeNoteByKTID(ktid) return render_template('web/f_noteinfo.html', notelist=notelist, noteinfo=noteinfo, menuinfo=menuinfo, webinfo=webinfo) else: flash('科研笔记不存在,请重新选择') return redirect(url_for('/resnotes')) # 联系我们 @app.route('/contact') def loadcontactinfo (): menuinfo = loadMenuInfo() webinfo = loadWebSiteInfo() contactinfo = webinfo[4] return render_template('web/f_contact.html', menuinfo=menuinfo, contactinfo=contactinfo) # 联系我们 @app.route('/uploadimage') def uploadimage (): return render_template('admin/uploadimage.html') # 联系我们 @app.route('/markd') def markd (): return render_template('web/showmarkdownfile.html')