imperialwool commited on
Commit
73ee427
1 Parent(s): 6aed9f0

idontwannadocumentthis

Browse files
app.py CHANGED
@@ -8,7 +8,7 @@ from transformers import AutoTokenizer, AutoModelForSequenceClassification
8
 
9
  #initing
10
  app = Flask(__name__)
11
- VERSION = '1.0 build121'
12
  app.config['JSON_AS_ASCII'] = False
13
 
14
  #error pages
@@ -64,6 +64,11 @@ def getJoke(): return jokes.getJoke(request)
64
  @app.route('/jokes/api/v1/sources', methods=['POST'])
65
  def getJokesSources(): return jokes.getSources(request)
66
 
 
 
 
 
 
67
  ###############
68
  #OSU API
69
  @app.route('/osu/api/v1/find-song', methods=['POST'])
 
8
 
9
  #initing
10
  app = Flask(__name__)
11
+ VERSION = '1.0 build123'
12
  app.config['JSON_AS_ASCII'] = False
13
 
14
  #error pages
 
64
  @app.route('/jokes/api/v1/sources', methods=['POST'])
65
  def getJokesSources(): return jokes.getSources(request)
66
 
67
+ ###############
68
+ #HOLIDAYS API (dont wanna document it)
69
+ @app.route('/holidays/api/v1/get', methods=['POST'])
70
+ def getHolidays(): return holidays.getHolidays(request)
71
+
72
  ###############
73
  #OSU API
74
  @app.route('/osu/api/v1/find-song', methods=['POST'])
routes/__init__.py CHANGED
@@ -2,4 +2,5 @@ from .jokes import *
2
  from .ytApi import *
3
  from .osuApi import *
4
  from .helpers import *
 
5
  from .siteRoutes import *
 
2
  from .ytApi import *
3
  from .osuApi import *
4
  from .helpers import *
5
+ from .holidays import *
6
  from .siteRoutes import *
routes/holidays/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from .getHolidays import *
routes/holidays/getHolidays.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from requests import get
2
+ import re
3
+
4
+ def getHolidays(request):
5
+ try:
6
+ site = get("https://calend.online/holiday/").text
7
+ site = site.partition('<ul class="holidays-list">')[2].partition('</ul>')[0]
8
+
9
+ patterns = [
10
+ r'<a\b[^>]*>',
11
+ r'</a\b[^>]*>',
12
+ r'<div\b[^>]*>',
13
+ r'</div\b[^>]*>',
14
+ r'<span\b[^>]*>',
15
+ r'</span\b[^>]*>',
16
+ r'<img\b[^>]*>',
17
+ r'<meta\b[^>]*>',
18
+ r'<li\b[^>]*>',
19
+ r'</li\b[^>]*>',
20
+ r'<small\b[^>]*>',
21
+ r'</small\b[^>]*>',
22
+ r'\b\d+\s+(?:лет|года)\b'
23
+ ]
24
+
25
+ for pattern in patterns: site = re.sub(pattern, '', site)
26
+ while " " in site: site = site.replace(" ", "")
27
+ things = list(set(site.split("\n")))
28
+ things.pop(0)
29
+ return {"status": "pass", "details": {"code": 200, "result": '\n'.join(things)}}
30
+ except Exception as e:
31
+ print(e)
32
+ return {"status": "error", "details": {"error_code": 500, "error_details": str(e)}}, 500