-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
61 lines (38 loc) · 1.39 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
59
60
#from .__init__ import db
from flask import Flask,request,Blueprint
import io
import os
import requests
import json
# Imports the Google Cloud client library
from google.cloud import vision_v1
#from google.oauth2 import servicefrom project
#import db, create_app, models_account
from google.protobuf.json_format import MessageToJson
from google.protobuf.json_format import MessageToDict
from google.cloud.vision import AnnotateFileRequest
from google.oauth2 import service_account
import proto
from labels import label
#from flask_sqlalchemy import SQLAlchemy
from flask import render_template,Blueprint
#from flask_login import login_required, current_user
#from models import User
credentials = service_account.Credentials.from_service_account_file(os.environ.get("GOOGLE_APPLICATION_CREDENTIALS"))
client = vision_v1.ImageAnnotatorClient(credentials=credentials)
#db = SQLAlchemy()
main = Blueprint('main', __name__)
@main.route('/')
def index():
#rec_id1 = mongo_black_list_collection.insert_one(emp_rec1)
return render_template('index.html')
@main.route('/profile')
#@login_required
def profile():
return render_template('profile.html',name="NPY")
@main.route('/website',endpoint = 'label', methods=['GET', 'POST'])
#@login_required
def web_request():
img_uri = request.args.get('params')
response = label(img_uri,client) #Get response as dict
return response