Le very basic osu! direct. Outdated, not used anymore.
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.

levbod.py 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import sys
  2. from multiprocessing.pool import ThreadPool
  3. import tornado.ioloop
  4. from web.handlers import listing
  5. from web.handlers import beatmapset
  6. from web.handlers import beatmap
  7. from db import pool
  8. from objects import glob
  9. from utils import console
  10. from constants import bcolors
  11. from objects import config
  12. console.colored(""" _ _ _
  13. | |___ _ _| |_ ___ _| |
  14. | | -_| | | . | . | . |
  15. |_|___|\_/|___|___|___|
  16. """, bcolors.BLUE)
  17. console.colored("""Le very basic osu!direct
  18. A temporary osu!direct api
  19. When bloodcat goes offline
  20. """, bcolors.GREEN)
  21. console.colored("""Use this until ~01/01/2017,
  22. then Howl will release a new
  23. mirror with api and everything
  24. """, bcolors.YELLOW)
  25. console.print_n("> Reading config.json...")
  26. glob.config = config.Config()
  27. try:
  28. glob.config.read()
  29. except FileNotFoundError:
  30. print("\nconfig.json doesn't exist. Generating a default one..")
  31. glob.config.write_default()
  32. sys.exit()
  33. console.done()
  34. console.print_n("> Connecting to db...")
  35. db_config = glob.config.config["db"]
  36. glob.db = pool.Pool(max_size=db_config["connections"],
  37. host=db_config["host"],
  38. user=db_config["username"],
  39. passwd=db_config["password"],
  40. db=db_config["database"],
  41. charset="utf8mb4")
  42. console.done()
  43. print("> Web server started on 0.0.0.0:{}".format(glob.config.config["server"]["port"]))
  44. glob.pool = ThreadPool(glob.config.config["server"]["threads"])
  45. tornado.web.Application([
  46. (r"/listing", listing.Handler),
  47. (r"/beatmapset", beatmapset.Handler),
  48. (r"/beatmap", beatmap.Handler),
  49. ]).listen(glob.config.config["server"]["port"])
  50. tornado.ioloop.IOLoop.instance().start()