monra commited on
Commit
890ca7d
2 Parent(s): f037f7d d374fcf

Merge pull request #33 from StudyingLover/main

Browse files
Files changed (2) hide show
  1. requirements.txt +1 -0
  2. run.py +13 -5
requirements.txt CHANGED
@@ -24,3 +24,4 @@ tornado>=6.3.2 # pinned to avoid a vulnerability
24
  PyExecJS
25
  browser_cookie3
26
  googletrans==4.0.0rc1
 
 
24
  PyExecJS
25
  browser_cookie3
26
  googletrans==4.0.0rc1
27
+ gevent
run.py CHANGED
@@ -2,7 +2,8 @@ from server.app import app
2
  from server.website import Website
3
  from server.backend import Backend_Api
4
  from json import load
5
-
 
6
 
7
  if __name__ == '__main__':
8
 
@@ -28,7 +29,14 @@ if __name__ == '__main__':
28
  methods=backend_api.routes[route]['methods'],
29
  )
30
 
31
- # Run the Flask server
32
- print(f"Running on port {site_config['port']}")
33
- app.run(**site_config)
34
- print(f"Closing port {site_config['port']}")
 
 
 
 
 
 
 
 
2
  from server.website import Website
3
  from server.backend import Backend_Api
4
  from json import load
5
+ from gevent import pywsgi
6
+ import socket
7
 
8
  if __name__ == '__main__':
9
 
 
29
  methods=backend_api.routes[route]['methods'],
30
  )
31
 
32
+ hostname = socket.gethostname()
33
+ ip_address = socket.gethostbyname(hostname)
34
+
35
+ # Run the Flask server by WSGI
36
+ print(f"Running on http://127.0.0.1:{site_config['port']}")
37
+ print(f"Running on http://{ip_address}:{site_config['port']}")
38
+
39
+ server = pywsgi.WSGIServer(('0.0.0.0', site_config['port']), app)
40
+ server.serve_forever()
41
+
42
+ print(f"Closing {ip_address}:{site_config['port']}")