-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcoreapi.py
More file actions
30 lines (27 loc) · 816 Bytes
/
coreapi.py
File metadata and controls
30 lines (27 loc) · 816 Bytes
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
import os
from flask import Flask, send_from_directory, render_template
def quick_share(app, path, address=None):
"""
quickly host given file at given address
:type app: Flask
:type address: str
:type path: str
:param app: Flask kind object
:param address: address to host at (yourdomain.com/address)
:param path: path where to get file from
:return:
"""
try:
splitted_path = os.path.split(path)
except Exception as e:
raise ValueError
try:
@app.route(address)
def quick_host():
try:
return send_from_directory(*splitted_path)
except Exception as e:
print(e)
return render_template('error.html', stack=e)
except Exception as e:
raise ValueError