def post_forum(): if 'username' in session: form = forumForm(request.form) retrieve_forum_count = root.child('forumCount').get() forumCount = int(retrieve_forum_count['forumCount']) if request.method == 'POST': text = form.forumText.data type = form.forumType.data newForum = Forum(text, type) increaseCount = forumCount + 1 newCount = root.child('forumCount/forumCount').set(increaseCount) newForum_db = root.child('Forum') newForum_db.push({ 'count': str(increaseCount), 'text': newForum.get_text(), 'type': newForum.get_type(), 'time': newForum.get_date(), 'username': session['username'], 'response': { 'response': 'empty' }, 'responseCount': 0 }) return redirect(url_for('forum')) return render_template('postForum.html', form=form) else: return redirect(url_for('login'))
def main(): # pubg forum f = Forum(id, token, username) f.run() ## currently a little buggy. # pubg reddit #r = Reddit(id, token, username) #r.run() #sqlite3 conn.close()
def post_forum(): form = forumForm(request.form) if request.method == 'POST': text = form.forumText.data type = form.forumType.data newForum = Forum(text,type) newForum_db = root.child('Forum') newForum_db.push( { 'text' : newForum.get_text(), 'type' : newForum.get_type(), 'time' : newForum.get_date() }) return redirect(url_for('forum')) return render_template('postForum.html',form=form)
db.commit() run += 1 rest += 1 if rest > 50: print(f'{run} Finished!') time.sleep(5) rest = 0 db.close() #----------------------=-----------------# #----------------------=-----------------# #----------------------=-----------------# #----------------------=-----------------# bot = Flask(__name__) Forum = Forum(bot) trade.init(bot) print(os.listdir('/home/runner/Pokezira/templates/static/')) socketio = SocketIO(bot) @bot.route('/profile') def profile(): session.clear() return 'hi' @bot.route('/cdn/sounds/music/<file>') def music(file): return send_file(f'./sounds/music/{file}') @bot.route('/cdn/sprite/<folder>/<sprite>')
root_dir = config['root_dir'] logger_file = config['logger_file'] or None database_file = config['database_file'] utils.read_file = partial(utils.read_file, root_dir) utils.construct_http_response = partial(utils.construct_http_response, HttpServer.SUPPORTED_HTTP_VERSION) server = HttpServer( root_dir=root_dir, host=host, port=int(port), logger_file=logger_file ) server._db = LoginDatabase(database_file) server._forum = Forum(server._db, "forum/") server._db.add_user("Admin", "", properties={ "uid": 1, "role": "admin", "threads": 0, "threads_ref": [], "posts": 0, "posts_ref": [], "reputation": 0, "reputation_content": {}, "ip": "127.0.0.1", "biography": "", "inbox": [] })
def main(): # pubg forum f = Forum(config.id, config.token, config.bot_name) f.run()
from exceptions import PermissionDenied from forum import Forum from thread import Thread from post import Post # This file does not need to contain any code. The marker runs program.py and tests the # classes imported above. You can put any testing code (that won't be run by the marker) # in the block below. if __name__ == '__main__': # Test your code here. This will not be checked by the marker. # Here is the example from the question. forum = Forum() thread = forum.publish('Battle of Zela', 'Veni, vidi, vici!', 'Caesar') thread.set_tags(['battle', 'brag'], 'Caesar') thread.publish_post(Post('That was quick!', 'Amantius')) thread.publish_post(Post('Hardly broke a sweat.', 'Caesar')) thread.publish_post(Post('Any good loot?', 'Amantius')) # Search by author print("The contents of Caesar's posts:") caesar_posts = forum.search_by_author('Caesar') print(sorted([p.get_content() for p in caesar_posts])) print() # Edit content of an existing post existing = thread.get_posts()[0] existing.set_content('I came, I saw, I conquered!', 'Caesar') # Upvote a post: existing.upvote('Cleopatra')
#!usr/bin/python3.9 from forum import Forum import logging import datetime from helper import open_file from settings import api_settings if __name__ == '__main__': logging.basicConfig(level=logging.INFO) logging.info('initializing forum connection') f = Forum(api_settings['forum_url'], api_settings['api_name'], api_settings['api_key']) logging.info('testing connectivity') f.check_connection() todayday = datetime.datetime.today().weekday() message = "" t_id = 0 logging.info('checking day') topics = [dic for dic in f.get_latest_topics(5)['topic_list']['topics'] if dic['pinned'] is False][:10] if todayday == 2: votes_tn = open_file("tn.train") if votes_tn: message = "Votes for this TN:\n" for item in votes_tn: message += item['who'] + ": " + item['where'] + "\n" else: message = "No votes from Chats for this FM :( \n" t_id = next(item['id'] for item in topics if "Tuesdayness" in item['title'])