generated from adgsenpai/ADGWEBSDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
42 lines (34 loc) · 1.06 KB
/
app.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
#ADGSTUDIOS - server.py
from flask import Flask,render_template,send_from_directory,jsonify,request
import WebComponents
import FetchData
from flask_cors import CORS
app = Flask(__name__,template_folder='./pages')
CORS(app)
# allows for files to be refreshed in server
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
RegData = WebComponents.ReturnNumberPlateData()
@app.route('/')
def home():
return render_template('index.html')
@app.route('/api/v1/returnRegData')
def returnRegData():
return jsonify(RegData)
@app.route('/api/v1/getData',methods=['POST'])
def getGeneralInformation():
if request.data:
data = request.get_json()
try:
imageURL = FetchData.get_image(data['city'])
except:
imageURL = 'none'
try:
generalInfo = FetchData.get_info(data['city'])
except:
generalInfo = 'none'
return {'imageURL':imageURL,'generalInfo':generalInfo}
else:
return {"error":"invalid syntax for API"}
#running server on port 5000 - you can change the values here
if __name__ == "__main__":
app.run(host="0.0.0.0",port=5000)