first commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
from webApp.interfaces.dependencies import *
|
||||
from webApp.interfaces.pagesController import *
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
from flask import send_from_directory, send_file, redirect, jsonify, make_response
|
||||
from webApp import webApp
|
||||
from config import config
|
||||
import os
|
||||
|
||||
@webApp.route('/css/<path:path>')
|
||||
def send_css(path):
|
||||
resp = make_response(send_from_directory(os.path.join(config['WEB_APP']['template_folder'], 'static/css'), path), 200)
|
||||
resp.headers['Cache-Control'] = 'public, max-age=31536000'
|
||||
return resp
|
||||
|
||||
@webApp.route('/js/<path:path>')
|
||||
def send_js(path):
|
||||
resp = make_response(send_from_directory(os.path.join(config['WEB_APP']['template_folder'], 'static/js'), path), 200)
|
||||
resp.headers['Cache-Control'] = 'public, max-age=31536000'
|
||||
return resp
|
||||
@@ -0,0 +1,54 @@
|
||||
from flask import abort, request, render_template, url_for, jsonify
|
||||
from webApp import *
|
||||
from webApp import webApp
|
||||
import gspread
|
||||
from oauth2client.service_account import ServiceAccountCredentials
|
||||
import json
|
||||
import datetime
|
||||
from config import config
|
||||
|
||||
# Авторизация Google API
|
||||
def authorize_google():
|
||||
# google_json = {}
|
||||
# for key in config["GOOGLE"].keys():
|
||||
# google_json[key] = config["GOOGLE"][key]
|
||||
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
|
||||
creds = ServiceAccountCredentials.from_json_keyfile_name("botforclinic-436512-0c117dd103a8.json", scope)
|
||||
# creds = ServiceAccountCredentials.from_json_keyfile_dict(google_json, scope)
|
||||
client = gspread.authorize(creds)
|
||||
return client
|
||||
|
||||
|
||||
# Обработка формы
|
||||
@webApp.route('/form_submit', methods=['POST'])
|
||||
def form_submit():
|
||||
data = json.loads(request.data)
|
||||
# {'fio': '', 'tel': '', 'email': '', 'passport': '', 'passport_date': '', 'postal_code': '', 'address': '', 'snils': '', 'inn': '', 'dob': ''}
|
||||
data['current_time'] = datetime.datetime.now().strftime("%d.%m.%Y, %H:%M")
|
||||
print(data)
|
||||
|
||||
# Авторизация и добавление данных в Google Sheets
|
||||
sheet = authorize_google().open("Информация о сотрудниках").sheet1
|
||||
sheet.append_row([
|
||||
data['fio'],
|
||||
data['tel'],
|
||||
data['email'],
|
||||
data['passport'][:4],
|
||||
data['passport'][4:],
|
||||
data['passport_issued_by'],
|
||||
data['passport_date'],
|
||||
data['postal_code'],
|
||||
data['address'],
|
||||
data['snils'],
|
||||
data['inn'],
|
||||
data['dob'],
|
||||
data['user_id'], # Записываем Telegram ID пользователя
|
||||
data['current_time'] # Записываем время отправки данных
|
||||
])
|
||||
|
||||
return jsonify({'success':True})
|
||||
|
||||
|
||||
@webApp.route('/')
|
||||
def main_page_2_0():
|
||||
return render_template('2.0/main_page.pug', user_id=request.args.get('user_id', None))
|
||||
Reference in New Issue
Block a user