Exemple #1
0
def main():
    if not os.path.exists(database.databaseName):
        print "No database found, initializing..."
        print "-" * 32
        database.initDatabase()
        print "Database initialized."
        print "-" * 32

    app.run()
def startServer():
    database.beginDataBaseConnection()
    database.initDatabase()
    server_address = (settings.server_location, int(settings.server_port))
    print('Starting server on %s port %s' % server_address)
    socket.setsockopt(pythonsocket.SOL_SOCKET, pythonsocket.SO_REUSEADDR, 1)
    socket.settimeout(None)
    socket.bind(server_address)
    socket.listen(5)
    socket.settimeout(None)
    thread = Thread(target=waitConnect)
    thread.start()
    servertick = Thread(target=serverTick)
    servertick.start()
Exemple #3
0
            print('rows: ' + str(rows))
            conn = sqlite3.connect('PostsRepostBotTest.db')
            c = conn.cursor()
            c.executemany(
                "INSERT INTO Posts (Date, Content, Url, Location, Author, Title) VALUES (?, ?, ?, ?, ?, ?)",
                rows)
            conn.commit()
            c.close()


threadCount = 0
threads = []
deleteOldThread = []
for i in config.subSettings:
    if i is not None:
        database.initDatabase(i[0])
        threads.append(findPosts(i))
        if i[1] is not None or i[2] is not None or i[3] is not None:
            deleteOldThread.append(
                Thread(target=database.deleteOldFromDatabase, args=(i, )))
            deleteOldThread[threadCount].start()
        threads[threadCount].start()
        threadCount += 1

deleteThread = Thread(target=deleteComment)

deleteThread.start()

deleteThread.join()
for i in range(0, len(threads)):
    if 'deleteOldThread' in vars():
Exemple #4
0
import random

import database
import models
import flask
from flask import jsonify
from flask import request

app = flask.Flask(__name__)

database.initDatabase()
print("App started")

@app.route('/api_python/todo', methods=['GET','POST'])
def todo():
    # IF get request, retrive todos
    if request.method == 'GET':
        objs = models.Todo.getTodosJSON()
        return jsonify(objs)

    # If post, create a new Todo post
    if request.method == 'POST':
        print("Post a new todo")
        body = request.get_json(force=True)

        x = random.randint(0, 1200)
        y = random.randint(0, 800)
        m1 = models.Todo( body['label'], x=x,y=y)
        m1.save()
        return jsonify({'message':'success'})