def main(port, bootstrap, auto): # signal.signal(signal.SIGINT, sigint_handler()) if bootstrap: # print("This is bootstrap node") wallet = Wallet() global_variable.node = Node(0, wallet) # Add bootstrap node in the peers' list ip_address = global_variable.bootstrapIp public_key_str = wallet.public_key # Create tuple of register data node_register_data = (public_key_str, ip_address) # Append it in nodes peers' list global_variable.node.peers.append(node_register_data) # edw an theloume kanoume wait mexri olo oi clients na graftoun # giati to diktuo den exei arxikopoihthei akoma, ara de mporoume na kanoume # transactions else: # print("This is user node") if register_with_bootstrap(port) is False: print("Problem establishing connecion -- exit") exit() # edw perimenoume anagastika na mas apantisei o bootstrap # to register request # ksekinaei se thread to loop pou diavazei input kai kalei # tis antistoixes sinartiseis tou node gia na parei # to balance, teleutaia transactions thr_client = Thread(target=client_input_loop) thr_client.start() thr_auto = Thread(target=send_coins_auto_after_initial_coins, args=[auto]) thr_auto.start() logging.getLogger('werkzeug').disabled = True os.environ['WERKZEUG_RUN_MAIN'] = 'true' app.run(host='0.0.0.0', port=port) thr_auto.join() thr_client.join()
c.execute(s_act, ("Blinds", "blinds", int(time.time()), 0)) pkey = c.lastrowid c.execute(s_thr, ("light", 5.0, pkey)) log.info("Registering blinds actuator") c.execute(s_act, ("Plant Watering", "plants_watering", int(time.time()), 0)) pkey = c.lastrowid c.execute(s_thr, ("moisture", 0.5, pkey)) log.info("Registering plants_watering actuator") except sqlite3.IntegrityError: pass try: conn.commit() except sqlite3.OperationalError as e: print(str(e)) conn.commit() c.close() holder = Holder( "sensors", HOST, PORT, [MQTT_TEMP, MQTT_HUM, MQTT_PRES, MQTT_LIGHT, MQTT_MOISTURE]) holder.on_end = store_record act_holder = Holder( "actuators", HOST, PORT, [MQTT_ACT_COND, MQTT_ACT_HEAT, MQTT_ACT_BLINDS, MQTT_ACT_WATER], actuator_on_message) app.run(debug=False, port=8080, host='0.0.0.0')
''' TODO: setup a websocket channel to talk to the front end TODO: receive config for creation of new mn TODO: action to delete old block chain cache, and cache .dat files TODO: display config for one MN, and allow saving it too: with password, or certificat TODO: test new MN creation TODO: use ListBox on left side with list of IPs, should be searchable/filterable and can select multiple IPs with checkbox TODO: Display information fromt he block explorer about block # and other relevant TODO: Des checkbox pour sélectionner les mn en groupe TODO: Une barre d'actions en haut pour appliquer aux mn sélectionné TODO: un évent pour refesh la page aux 5 min TODO: masternode start from this script (via RPC) TODO: Enable multi threading or non blocking of requests/responses, - WSGI, gunicorn, multiprocessing (python), - https://stackoverflow.com/questions/40912982/how-can-my-twisted-klein-app-listen-on-multiple-ports DONE: ''' from rest import app from config import config if __name__ == '__main__': app.run(host=config["Listen"]["host"], port=config["Listen"]["port"])
from __future__ import print_function from binascii import hexlify from rest import app, init_db import os app.API_KEY = hexlify(os.urandom(20)).decode() print('api key is: {}'.format(app.API_KEY)) app.config['DB_PATH'] = os.path.join(os.getcwd(), 'wifi_manager/schema') app.config['DB_SOURCE'] = os.path.join(app.config['DB_PATH'], 'schema.sql') app.config['DB_INSTANCE'] = os.path.join(app.config['DB_PATH'], 'schema.db') app.config['DEBUG'] = False init_db() app.run(host='0.0.0.0')
from rest import app if __name__ == '__main__': app.run()
#!/usr/bin/python #-*- coding: utf-8 -*- from rest import app port = 5002 app.run(debug=True, port=port, host='0.0.0.0')
from rest import app app.run(port=8081, server='gevent', debug=True)
#!/usr/bin/env python from rest import app from flask import render_template from rest.models import User @app.route("/") def index(): return "Welcome to my site." @app.route("/hello/<user>") def hello_user(user): result = User.query.filter_by(username=user).first() if result: return render_hello(result.username + '@' + result.email) else: return render_hello(None) def render_hello(name): response = render_template('hello.html', name=name) print response return response if __name__ == "__main__": app.debug = True app.run()
from rest import app from bot.bot import runBot from threading import Thread thread = Thread(target=runBot, daemon=True) thread.start() app.run(host="localhost", port=4067)
api.add_resource(SignupHandler, '/signup') api.add_resource(UserItems, '/<string:username>') api.add_resource(ItemHandler, '/item/<int:item_id>') api.add_resource(CreateItem, '/item/create') api.add_resource(CheckExistingUser, '/check_existing/<string:username>') api.add_resource(Search, '/search/<string:search_query>') # check secret key for JSON web tokens try: os.environ['SECRET_KEY'] except KeyError: print('Please set the secret_key') exit() #initialize orm db.init_app(app) try: # for deploying on heroku database_url = os.environ['DATABASE_URL'] except KeyError: # running locally database_url = 'sqlite:///test.db' app.config['SQLALCHEMY_DATABASE_URI'] = database_url if __name__ == "__main__": with app.app_context(): db.create_all() app.run(debug=True)
from rest import app class handler(WSGIRequestHandler): def __init__(self, request, client_address, server): server.get_app = lambda: app server.base_environ = self.setup_environ() WSGIRequestHandler.__init__(self, request, client_address, server) def setup_environ(self): # Set up base environment env = {} env['SERVER_NAME'] = 'FAKE WSGI server' env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PORT'] = 1234 env['REMOTE_HOST'] = '' env['CONTENT_LENGTH'] = '' env['SCRIPT_NAME'] = '' return env def runner(): httpd = http.server.HTTPServer(('', 7004), handler) httpd.serve_forever() if __name__ == '__main__': app.run(port=7004) #runner()
__author__ = 'jason' from rest import app app.run(port=8099, host='0.0.0.0') # app.run(port=app.config['PORT'], host='0.0.0.0')
#!/usr/bin/python #-*- coding: utf-8 -*- from rest import app port=5002 app.run(debug=True, port=port)
from rest import app if __name__ == "__main__": app.run( host=app.config.get("HOST", "0.0.0.0"), port=app.config.get("PORT", 6000) )
#!/usr/bin/python #-*- coding: utf-8 -*- from rest import app port=5002 app.run(debug=True, port=port, host='0.0.0.0')
"""If you want to run API server""" from rest import app if __name__ == '__main__': app.run(host='127.0.0.1', port=5000, debug=True)