coding cp1251 from flask import Flask from flask import request jsonif

 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
# -*- coding: cp1251 -*-
from flask import Flask
from flask import request, jsonify, render_template, json
import os
import datetime
import MySQLdb
app = Flask(__name__, static_folder='.\\static')
log_file = 'C:\ProjectI\output.log'
def log(s):
global log_file
f = open(log_file, 'a')
now = datetime.datetime.now().strftime('%d.%m.%Y %H:%M:%S')
f.write(now + ': ' + s + '\n')
f.close()
@app.route('/')
def index():
return render_template('index.html')
@app.route('/first')
def first():
db = MySQLdb.connect(host = "127.0.0.1", user = "root", db = "restaurant", charset = 'cp1251')
cursor = db.cursor()
cursor.execute("select res_name from rest_name")
name = cursor.fetchall()
return jsonify(result = name)
@app.route('/per')
def per():
restaurant =request.args.get('restaurant')
DOW =request.args.get('DOW')
D1 =request.args.get('D1')
D2 =request.args.get('D2')
TO1 =request.args.get('TO1')
TO2 =request.args.get('TO2')
CP =request.args.get('CP')
par =request.args.get('par')
return jsonify(A = restaurant, B = DOW, C =D1, D = D2, E =TO1, F =TO2, G = CP, H = par) return jsonify(result = name)
@app.route('/ABC')
def ABC():
restaurant ="Шкварок"
day =(0,1,2,3,4,5,6)
day=str(day)
date = ["02.01.2013","02.02.2013"]
time = ["8:30","19:30"]
count_people =(1,2)
count_people=str(count_people)
par =0
db = MySQLdb.connect(host = "127.0.0.1", user = "root", db = "restaurant", charset = 'cp1251')
cursor = db.cursor()
if par==0:
t="proceeds"
elif par==1:
t="margin"
elif par==2:
t="margin_M"
sql="SELECT * from Шкварок;"
cursor.execute(sql)
return jsonify(A = sql)
if (__name__ == '__main__'):
app.run(debug = True, port = 5000)