You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.py 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. from flask import Flask, render_template
  2. from flask_sock import Sock
  3. import flask
  4. import hot_reload_mod_i2
  5. import gmod
  6. import os
  7. # app = Flask(__name__)
  8. app = Flask(__name__,template_folder = r"../js_client")
  9. sock = Sock(app)
  10. gmod.glob["sock"] = sock
  11. gmod.glob["app"] = app
  12. class Eobj():
  13. pass
  14. eobj = Eobj()
  15. gmod.gx =eobj
  16. import rld_m0
  17. import rld_m1
  18. import rld_m2
  19. import rld_m3
  20. # import rld_m4
  21. # import rld_m5
  22. p=print
  23. @app.route('/')
  24. def index():
  25. print("::::::::::::::;")
  26. return render_template('jsyncdb_index_v5.html')
  27. return render_template('index.html')
  28. # r'''
  29. @app.route('/shared_libs/<path:path>')
  30. def send_report2(path):
  31. return flask.send_file('../js_client/jquery-3.5.1.min.js')
  32. @app.route('/<path:path>')
  33. def send_report(path):
  34. # return flask.send_from_directory('templates', path)
  35. return flask.send_from_directory(r"../js_client", path)
  36. return flask.send_from_directory('./', path)
  37. # '''
  38. @sock.route('/echo')
  39. def echo(sock):
  40. while True:
  41. data = sock.receive()
  42. sock.send(data)
  43. # @sock.route('/echo_c1')
  44. # def echo_coll(sock):
  45. # p("echo_coll app")
  46. # while True:
  47. # data = sock.receive()
  48. # sock.send(data)
  49. # @sock.route('/<path:path>')
  50. # def echo23(sock,*a,**kw):
  51. # p("E2",a,kw)
  52. # while True:
  53. # data = sock.receive()
  54. # sock.send(data)
  55. # for en in dir(sock):
  56. # p(en)
  57. # p("echo23",echo23)
  58. # p("~83293298383838383")
  59. r'''
  60. for en in dir(sock):
  61. print(".",en)
  62. for en in dir(app):
  63. print("~",en)
  64. '''
  65. # generated by bing seems to work
  66. @app.route("/ldir")
  67. def list_directory():
  68. # Get the list of files and directories
  69. # items = os.listdir(DIRECTORY_PATH)
  70. items = os.listdir("../js_client")
  71. # Filter out hidden files and directories
  72. items = [item for item in items if not item.startswith(".")]
  73. # Create an HTML string with the list of items as links
  74. html_content = "<h1>Contents of the Directory</h1><ul>"
  75. html_links = ""
  76. other_links = ""
  77. for item in items:
  78. p([item])
  79. if "html" in item:
  80. html_links += f"<li><a href='{item}'>{item}</a></li>"
  81. else:
  82. other_links += f"<li><a href='{item}'>{item}</a></li>"
  83. # link = (request.path + '/' if request.path != '/' else '') + item
  84. html_content+=html_links
  85. html_content+="<br>"
  86. html_content+=other_links
  87. html_content += "</ul>"
  88. # Return the HTML content directly
  89. return html_content
  90. # end generated by bing
  91. import inspect
  92. print("APP_ORIG",sock.route)
  93. print("APP_ORIG",app.route)
  94. print("APP_ORIG",inspect.getfile(app.route))
  95. print("APP_ORIG",app.url_map)
  96. if __name__ == '__main__':
  97. pass
  98. # socketio.run(app, debug=True)
  99. # app.run(debug=True,host='0.0.0.0')
  100. app.run(debug=True,host='0.0.0.0')
  101. # sock.run(app,host='0.0.0.0', debug=True,allow_unsafe_werkzeug=True)