-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
58 lines (45 loc) · 1.74 KB
/
main.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
from sanic import Sanic
from sanic.config import Config
Config.KEEP_ALIVE = False
completed = {}
pending = {}
failed = {}
created = {}
finished = {}
def make_app():
app = Sanic(__name__)
@app.route('/v1/images/upload',methods=["POST"])
async def upload(request):
from controllers.UrlCrawler import UrlCrawler
from controllers.Imgur import Imgur
return await UrlCrawler().fetcher(request,Imgur(),
completed=completed,
pending=pending,
failed=failed,
created=created,
finished=finished
)
@app.route('/v1/images')
async def get_uploaded(request):
from controllers.Status import Status
return Status.get_status(request,
completed=completed,
pending=pending,
failed=failed,
created=created,
finished=finished
)
@app.route('/v1/images/upload/<jobId>')
async def get_uploaded_id(request,jobId):
from controllers.Status import Status
return Status.get_status_id(request,jobId,
completed=completed,
pending=pending,
failed=failed,
created=created,
finished=finished
)
return app
if __name__ == '__main__':
app = make_app()
app.run(debug=False, host='0.0.0.0', port='8001')