-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
27 lines (20 loc) · 755 Bytes
/
Copy pathrun.py
File metadata and controls
27 lines (20 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Start the Reddit Scraper API.
python run.py # http://localhost:8000
PORT=9000 python run.py # another port
Then: curl "http://localhost:8000/posts/comments?post=z1c9z"
"""
import bottle
from cheroot import wsgi
import config
import routes # noqa: F401 (mounts the routes on bottle's default app)
def main():
app = bottle.default_app()
print(f"Reddit Scraper listening on http://localhost:{config.PORT}/")
print(f"Try: curl \"http://localhost:{config.PORT}/posts/comments?post=z1c9z\"")
server = wsgi.Server(("0.0.0.0", config.PORT), app, server_name="reddit-scraper", numthreads=16)
try:
server.start()
except KeyboardInterrupt:
server.stop()
if __name__ == "__main__":
main()