main.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import os
  2. from flask import Flask
  3. BASE_DIR = os.path.dirname(__file__) #表示本项目运行时的当前目录(基准路径)
  4. print(BASE_DIR)
  5. app = Flask(__name__, template_folder=os.path.join(BASE_DIR, "templates"), #flask模板文件(HTML文件)存放路径的文件夹名称
  6. static_folder=os.path.join(BASE_DIR, "static"), #样式表文件、图片等静态资源存放的物理路径的文件夹名称
  7. static_url_path="/static") #虽然与上面的static同名(当然也可以不同),但意义不同,这里指在运行时(浏览器)要去加载样式表文件、图片等资源时的url路径
  8. app.secret_key = 'fkdjsafjdkfdlkjfadskjfadskljdsfklj'
  9. app.jinja_env.auto_reload = True
  10. app.config['TEMPLATES_AUTO_RELOAD'] = True
  11. # app.config['IMG_UPLOAD_FOLDER'] = 'static/vditor/uploads/'
  12. app.config['IMG_UPLOAD_FOLDER'] = 'static/uploads/img_notes/' #文本编辑器中上传图像的路径
  13. #app.config['IMG_UPLOAD_FOLDER'] = 'static/uploads/img_comms/'
  14. # app.config['IMG_UPLOAD_URL'] = '/vditor/uploads'
  15. app.config['IMG_UPLOAD_URL'] = 'static/uploads/img_notes/'
  16. app.config['File_UPLOAD_FOLDER'] = 'static/uploads/files/'
  17. app.config['UPLOAD_FOLDER_IMG_Pro'] = 'static/uploads/images_pro/'
  18. app.config['UPLOAD_FOLDER_IMG_Teach'] = 'static/uploads/img_teachers/'
  19. app.config['UPLOAD_FOLDER_IMG_Student'] = 'static/uploads/img_students/'
  20. app.config['UPLOAD_FOLDER_IMG_ReTopic'] = 'static/uploads/img_retopics/'
  21. app.config['UPLOAD_FOLDER_IMG_Patent'] = 'static/uploads/img_patents/'
  22. app.config['UPLOAD_FOLDER_IMG_Paper'] = 'static/uploads/img_papers/'
  23. app.config['UPLOAD_FOLDER_IMG_Knowtopic'] = 'static/uploads/img_knowtopic/'
  24. app.config['UPLOAD_FOLDER_IMG_Note'] = 'static/uploads/img_notes/'
  25. app.config['UPLOAD_FOLDER_IMG_News'] = 'static/uploads/img_news/'
  26. app.config['UPLOAD_FOLDER_VIDEO_Note'] = 'static/uploads/video_notes/' #视频
  27. app.config['UPLOAD_FOLDER_temp'] = 'static/uploads/temp/'
  28. app.config['UPLOAD_FOLDER_md'] = 'static/uploads/md/'
  29. app.config['WTF_CSRF_CHECK_DEFAULT'] = False
  30. #将代码放入多个文件,再来调用
  31. with app.app_context():
  32. import bussiness.b_userinfo, bussiness.b_roleinfo
  33. import bussiness.b_peopletype, bussiness.b_teacherinfo
  34. import bussiness.b_researcharea, bussiness.b_researchtopic
  35. import bussiness.b_patentinfo, bussiness.b_paperinfo
  36. import bussiness.b_knowledgetopictype, bussiness.b_knowledgetopic, bussiness.b_knowledgenote
  37. import bussiness.b_menuinfo, bussiness.b_menuinfo, bussiness.b_foreweb
  38. import bussiness.b_spornor_manage, bussiness.b_websiteinfo
  39. import bussiness.b_markdown, bussiness.b_wordop,bussiness.b_studentinfo
  40. import bussiness.b_researchtopic, bussiness.b_researcharea
  41. if __name__ == '__main__':
  42. with app.app_context():
  43. app.run(host="0.0.0.0", port=8080, debug=True)