import time import requests from db import db_session from db.shared import Shared from config import * db_session.global_init(gdp('shared_data.db')) db_sess = db_session.create_session() for shared in db_sess.query(Shared).all(): db_sess.delete(shared) db_sess.commit() db_sess.add(Shared(data='')) db_sess.commit() db_sess.add(Shared(data='')) db_sess.commit() while True: db_sess = db_session.create_session() request = db_sess.query(Shared).filter(Shared.id == 1).first() answer = db_sess.query(Shared).filter(Shared.id == 2).first() if request.data and not answer.data: send = eval(request.data) try: res = str( getattr(requests, send['method'])(SERVER + send['add'], json=send).json()) except Exception: res = str({'result': 'unknown error'}) answer.data = res db_sess.merge(answer) db_sess.commit() request.data = ''
from data.Category import Category from data.Department import Department from flask_login import LoginManager, login_user, logout_user, login_required, current_user from forms.register import RegisterForm from forms.login import LoginForm from forms.job import JobForm from forms.department import DepartmentForm import jobs_api import users_api from flask_restful import Api import users_resource import jobs_resource app = Flask(__name__) app.config['SECRET_KEY'] = 'my_skey_lol_lmao' db_session.global_init('db/blogs.sqlite') api = Api(app) app.register_blueprint(jobs_api.blueprint) app.register_blueprint(users_api.blueprint) api.add_resource(users_resource.UserListResource, '/api/v2/users') api.add_resource(users_resource.UserResource, '/api/v2/users/<int:user_id>') api.add_resource(jobs_resource.JobListResource, '/api/v2/jobs') api.add_resource(jobs_resource.JobResource, '/api/v2/jobs/<int:job_id>') login_manager = LoginManager() login_manager.init_app(app)
from aiogram import Bot, Dispatcher, types from aiogram.contrib.fsm_storage.memory import MemoryStorage from data import config from db import db_session bot = Bot(token=config.BOT_TOKEN, parse_mode=types.ParseMode.HTML) db_session.global_init("db/user_info.db") storage = MemoryStorage() dp = Dispatcher(bot, storage=storage)
def __init__(self): db_session.global_init(gdp('shared_data.db')) self.waiting = '' self.saved = ''