def get_links(): try: notion_api = NotionApi() current_day = notion_api.current_day() current_week = notion_api.current_week() return jsonify( current_day=app_url(current_day.get_browseable_url()), current_week=app_url(current_week.get_browseable_url()), ) except Exception: return 'Failed fetching current links', 500
import json from notion_api import notion_api from utils import app_url, fast_tags_for_task try: tasks = [{ "uid": row.id, "title": "[" + row.status + "] " + row.title, "subtitle": "Tags: " + fast_tags_for_task(row), "variables": { "taskName": row.title, "url": app_url(row.get_browseable_url()) }, "arg": row.get_browseable_url(), "match": row.title + " " + row.status + " " + fast_tags_for_task(row), "copy": row.title, "largetype": row.title } for row in notion_api.get_current_tasks()] empty_item = [{ "uid": "nothing", "title": "Nothing... Maybe start something", }]
#!/Users/bryanfisher/.pyenv/versions/3.8.2/bin/python3 import sys from notion_api import notion_api from utils import app_url try: print(app_url(notion_api.current_day().get_browseable_url())) except Exception as e: # Print out nothing on STDOUT (missing value means means operation was unsuccessful) sys.stderr.write(e)
parser = reqparse.RequestParser() parser.add_argument('ImgString', type=str, required=True, location='form') args = parser.parse_args() rst = None imgString = args['ImgString'].encode().split(b';base64,')[-1] try: b64_image = base64_to_PIL(imgString) if b64_image is not None: b64_image = np.array(b64_image) result = text_predict(b64_image) text = ' '.join([i['text'] for i in result]) rst = { 'code': "success", 'text': text } except ValueError: rst = { "code": "FAILURE", "errMsg": "ocr访问出错", "id": "1501" } return rst api.add_resource(ImageIdentify, app_url(version, '/ocr')) if __name__ == '__main__': app.run(host='0.0.0.0', debug=False)
#!/Users/bryanfisher/.pyenv/versions/3.8.2/bin/python3 import sys import json from notion_api import notion_api from utils import app_url, fast_tags_for_task try: tasks = [{ "uid": row.id, "title": "[" + row.status + "] " + row.title, "subtitle": "Tags: " + fast_tags_for_task(row), "variables": {"taskName": row.title, "url": app_url(row.get_browseable_url())}, "arg": row.get_browseable_url(), "match": row.title + " " + row.status + " " + fast_tags_for_task(row), "copy": row.title, "largetype": row.title } for row in notion_api.get_current_tasks()] empty_item = [{ "uid": "nothing", "title": "Nothing... Maybe start something", }] if not tasks: print(json.dumps({"items": tasks + empty_item})) else: print(json.dumps({"items": tasks})) except Exception as e: