-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwsgi.py
78 lines (66 loc) · 2.48 KB
/
wsgi.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from flask import Flask, jsonify
from flask_restful import Api, Resource
import requests
from bs4 import BeautifulSoup, SoupStrainer
import json
from backend.facebook.parser import FBParser
from backend.daily.parser import DailyParser
app = Flask(__name__)
app.config['RESTFUL_JSON'] = {
'ensure_ascii': False
}
api = Api(app)
fbparser = FBParser()
dailyparser = DailyParser()
# http://preview.risevision.com/Viewer.html?type=presentation&id=269cbe4e-4b35-4e4e-9f39-8cac09f29202
class HelloWorld(Resource):
def get(self):
return {'hello': 'world'}
# Parse Bitstop info from facebook and post it to db/redis
class BitStop(Resource):
def get(self):
response = fbparser.get_fb_post(sub_url="/bitstopkohvik/posts/")
return {"bitstop": response}
def post(self):
pass
class Rahvatoit(Resource):
def get(self):
response = fbparser.get_fb_post(sub_url="/rahvatoitttu/posts/", numberOfPosts=1)
return {"rahvatoit": response}
def post(self):
pass
class ITDaily(Resource):
def get(self):
response = dailyparser.get_daily_menu("https://päevapakkumised.ee/tallinn/ttü-it-maja-daily")
return {"IT maja daily" : response}
def post(self):
pass
class VIKorpusDaily(Resource):
def get(self):
response = dailyparser.get_pdfalt_menu("http://www.daily.ee/files/dn_daily_nadalamenuu_ttu_6_korpus.pdf")
return {"VI korpuse daily" : response}
def post(self):
pass
class AllMenus(Resource):
def get(self):
bitstopmenu = fbparser.get_fb_post(sub_url="/bitstopkohvik/posts/")
rahvatoitmenu = fbparser.get_fb_post(sub_url="/rahvatoitttu/posts/", numberOfPosts=1)
itdailymenu = dailyparser.get_daily_menu("https://päevapakkumised.ee/tallinn/ttü-it-maja-daily")
#vikorpusdailymenu = dailyparser.get_pdfalt_menu("http://www.daily.ee/files/dn_daily_nadalamenuu_ttu_6_korpus.pdf")
# testing out if auto commit works 5
return {"Bitstop" : bitstopmenu,
"Rahvatoit": rahvatoitmenu,
"IT Daily": itdailymenu
#"VI korpuse Daily": vikorpusdailymenu
}
def post(self):
pass
api.add_resource(BitStop, "/bitstop")
api.add_resource(Rahvatoit, "/rahvatoit")
api.add_resource(ITDaily, "/itdaily")
api.add_resource(VIKorpusDaily, "/vidaily")
api.add_resource(AllMenus, "/all")
if __name__ == '__main__':
app.run(debug=True, host="0.0.0.0")