The crux.sexy website
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 

94 satır
2.5 KiB

  1. from flask import Flask, render_template, redirect, request
  2. from time import time
  3. from urllib.parse import urlparse, unquote
  4. from markdown2 import markdown
  5. import requests
  6. import json
  7. from bs4 import BeautifulSoup
  8. app = Flask(
  9. __name__,
  10. static_url_path='',
  11. static_folder='static/',
  12. template_folder='templates/'
  13. )
  14. @app.route('/')
  15. def index():
  16. return render_template("index.html", nightly=False)
  17. @app.route('/nightly')
  18. def nightly():
  19. return render_template("index.html", nightly=True)
  20. @app.route('/agegate')
  21. def agegate():
  22. url = request.args.get("url", default=None)
  23. try:
  24. if urlparse(url).netloc and urlparse(url).netloc[-9:] != "crux.sexy":
  25. print("URL is not pointing at crux.sexy")
  26. url = "https://crux.sexy/"
  27. except:
  28. url = "https://crux.sexy"
  29. try:
  30. r = requests.get(url, cookies={"agegate": "true"})
  31. soup = BeautifulSoup(r.text, "html5lib")
  32. headers = []
  33. for item in soup.head.findAll("meta"):
  34. if item.has_attr("name") and item["name"] == "viewport":
  35. continue
  36. if item.has_attr("content"):
  37. headers.append(str(item))
  38. except:
  39. headers = []
  40. return render_template("age-gate.html", url=url, headers="\n".join(headers))
  41. @app.route('/accept')
  42. def accept():
  43. url = request.args.get("url", default=None)
  44. if urlparse(url).netloc and urlparse(url).netloc[-9:] != "crux.sexy":
  45. print("oops")
  46. url = "/"
  47. if not url:
  48. url = "/"
  49. res = redirect(url, 307)
  50. res.set_cookie("agegate", "true", time() + 60*60*24*365, domain="crux.sexy")
  51. return res
  52. @app.route('/changelog')
  53. def changelog():
  54. game_names = ["stroll", "feast", "gorge", "satiate", "macrovision"]
  55. games = []
  56. for game in game_names:
  57. data = json.load(open("{0}/changelog.json".format(game)))
  58. keys = sorted(data.keys())[::-1]
  59. versions = []
  60. for key in keys:
  61. versions.append({"version": key, "changes": markdown(data[key])})
  62. games.append({"name": game, "versions": versions})
  63. return render_template("changelog.html", games=games)
  64. @app.route('/commits')
  65. def commits():
  66. game_names = ["stroll", "feast", "gorge", "satiate", "macrovision"]
  67. games = []
  68. for game in game_names:
  69. data = json.load(open("commits/{0}.json".format(game)))
  70. games.append({"name": game, "commits": data})
  71. return render_template("commits.html", games=games)
  72. if __name__ == "__main__":
  73. app.run(debug=True, host='0.0.0.0', port=5002)