-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserv.py
More file actions
89 lines (70 loc) · 2.08 KB
/
serv.py
File metadata and controls
89 lines (70 loc) · 2.08 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from flask import Flask, jsonify, request, redirect, url_for, make_response
import process as data
from flask_httpauth import HTTPBasicAuth
app = Flask(__name__)
app.config['JSON_AS_ASCII'] = False
app.secret_key = 'f76v7v67x6v7dx6v876dx7vdx8'
auth = HTTPBasicAuth()
tutorials = [
{
'id': 1,
'title': 'Строка 1',
'description': 'Описание 1'
},
{
'id': 2,
'title': 'Строка 2',
'description': 'Описане 2'
}
]
@auth.get_password
def get_password(username):
if username == 'ocrv':
return 'ocrv'
return None
@auth.error_handler
def unauthorized():
return make_response(jsonify({'error': 'Unauthorized access'}), 401)
@app.route('/')
def index():
return "Hello, World!"
@app.route('/tutorials', methods=['GET'])
@auth.login_required
def get_list():
query2 = request.args
print(query2)
query = request.args.get('MONTH')
query1 = request.args.get('poezd')
print(query)
print(query1)
return jsonify(tutorials)
# http://172.22.202.84:5000/InvestigationSet?MONTH=202112&poezd=57386388007008
@app.route('/InvestigationSet', methods=['GET'])
@auth.login_required
def get_investigationSet():
month = request.args.get('MONTH')
poezd = request.args.get('poezd')
set = data.investigationSet(month, poezd)
return jsonify(set)
@app.route('/InvestigationSFSet', methods=['GET'])
@auth.login_required
def get_InvestigationSFSet():
month = request.args.get('MONTH')
poezd = request.args.get('poezd')
set = data.investigationSFSet(month, poezd)
return jsonify(set)
@app.route('/StNumberingSet', methods=['GET'])
@auth.login_required
def get_stNumberingSet():
month = request.args.get('MONTH')
poezd = request.args.get('poezd')
set = data.stNumberingSet(month, poezd)
return jsonify(set)
@app.route('/PoezdSuggest', methods=['GET'])
@auth.login_required
def get_poezdSuggestSet():
poezd = request.args.get('poezd')
set = data.poezdSuggestSet(poezd)
return jsonify(set)
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)