def run(self): cx_Logging.Debug("stdout=%r", sys.stdout) sys.stdout = open(os.path.join(self.directory, "stdout.log"), "a") sys.stderr = open(os.path.join(self.directory, "stderr.log"), "a") #sys.stdout = open(os.path.join("C:\\Data\\logs\\", "stdout.log"), "a") #sys.stderr = open(os.path.join("C:\\Data\\logs\\", "stderr.log"), "a") app.run(host="127.0.0.1",port=5123) self.stopRequestedEvent.wait() self.stopEvent.set()
import os import telegram from flask import request from chat.cerebrum import Cerebrum from init import app @app.route("/", methods=["GET", "POST"]) def hello(): if request.method == "GET": return "Not much to see here" elif request.method == 'POST': bot = telegram.Bot(token=os.getenv('TELEGRAM_TOKEN', 'empty_token')) update = telegram.Update.de_json(request.json) text = Cerebrum(update).get_respond() bot.sendMessage(update.message.chat_id, text=text, parse_mode='Markdown') return text if __name__ == "__main__": app.run()
oauth_args = dict(client_id=FACEBOOK_APP_ID, client_secret=FACEBOOK_APP_SECRET, grant_type='client_credentials') url = 'https://graph.facebook.com/oauth/access_token?'+\ urllib.urlencode(oauth_args) print(url + "\n") f = urllib.urlopen(url) s = f.read() print(s) oauth_access_token = s[s.find("access_token=") + 13:] print(oauth_access_token) #graph = facebook.GraphAPI(oauth_access_token) #profile = graph.get_object("me") #print(dir(profile)) return dict(auth=authenticate, log=log) @app.route("/marknote/clear_session") def clear_session(): session.clear() return redirect("/marknote/time/1") if __name__ == '__main__': app.debug = True #app.run(host='127.0.0.1') app.run(host='192.168.1.2')
scores = Player.query.filter_by(id=room).order_by(Player.score).all() return jsonify(map(lambda x: x.serialize(), scores)) """ Construction Zone """ """ Resets gamestate to guessing if another round can happen else end """ @app.route("/gamecontroller/<string:room_id>/next") def get_next_stage(room_id): images = map(lambda x: x.drawing, Player.query.filter_by(id=room_id).all()) images_viewed = Room.query.filter_by(id=room_id).first().viewing Room.query.filter_by(id=room_id).update( dict(gameState=2, scoresUpdated=0, viewing=images_viewed + 1)) Player.query.filter_by(id=room_id).update(dict(choice=u'', guess=u'')) db.session.commit() return jsonify(2) """ Get gamestate """ @app.route("/gamecontroller/<string:room_id>/state") def get_state(room_id): state = Room.query.filter_by(id=room_id).first().gameState return jsonify(state) if __name__ == "__main__": app.run(debug=True, threaded=True)
import init from init import app from read import * from create import * from delete import * from update import * f = open("host.config", "r") ip = f.readline() p = int(f.readline()) app.run(host=ip, port=p)
from api import CardPaymentAPI, RequestPaymentAPI, BankPaymentAPI, SecurityAPI from init import app, api from database import * api.add_resource(CardPaymentAPI, '/cardPayment/<int:id>', endpoint='cardPaymentId') api.add_resource(CardPaymentAPI, '/cardPayment', endpoint='cardPayment') api.add_resource(RequestPaymentAPI, '/requestPayment', endpoint='requestPayment') api.add_resource(BankPaymentAPI, '/bankPayment', endpoint='bankPayment') api.add_resource(SecurityAPI, '/security', endpoint='security') database.create_all() if __name__ == '__main__': app.run(port=2700, debug=True)
from init import app app.config["DEBUG"] = True app.run(host='0.0.0.0', port=6969)
from init import app from routes import * from oauth.blueprint import oauth app.register_blueprint(oauth, url_prefix='/oauth') if __name__ == '__main__': app.run(host='0.0.0.0', debug=True)
from init import app # pragma: no cover import routes # noqa: F401 # pragma: no cover if __name__ == '__main__': # pragma: no cover app.run(host="127.0.0.1", port=8080, debug=True) # pragma: no cover
# create secret key for form to avoid CSRF attack app.secret_key = os.urandom(32) # register blueprint app.register_blueprint(patient_blueprint) app.register_blueprint(doctor_blueprint) app.register_blueprint(clerk_blueprint) @app.errorhandler(404) def not_found(error): return make_response(jsonify({'error': 'Not found'}), 404) @app.route('/logout') @auth.login_required def logout(): return '' @auth.get_password def get_password(username): if username == APIKEY: return APIPASS return None @auth.error_handler def unauthorized(): return make_response(jsonify({'error': 'Unauthorized access'}), 403) if __name__ == '__main__': app.run(debug=DEBUG, host='0.0.0.0', port=8081)
oauth_args = dict(client_id = FACEBOOK_APP_ID, client_secret = FACEBOOK_APP_SECRET, grant_type = 'client_credentials') url = 'https://graph.facebook.com/oauth/access_token?'+\ urllib.urlencode(oauth_args) print(url+"\n") f = urllib.urlopen(url) s = f.read() print(s) oauth_access_token = s[s.find("access_token=")+13:] print(oauth_access_token) #graph = facebook.GraphAPI(oauth_access_token) #profile = graph.get_object("me") #print(dir(profile)) return dict(auth=authenticate, log=log) @app.route("/marknote/clear_session") def clear_session(): session.clear() return redirect("/marknote/time/1") if __name__=='__main__': app.debug = True #app.run(host='127.0.0.1') app.run(host='192.168.1.2')
@app.route('/<path:path>') def catch_all(path): if current_user.is_authenticated or autorizedStatic(path): return app.send_static_file(path) if sso_enabled is True: # if loginSSO(): return app.send_static_file(path) # return app.make_response(render_template('505.html')), 505 if oauth_enabled is True: return render_template("login.html") @app.before_first_request def before_first(): run_init_config() if __name__ == '__main__': with app.app_context(): '''App Conext Here''' if (setup_ok): app.debug = app.config["DEBUG_MODE"] # run_init_config() app.app_context().push() app.run("0.0.0.0", app.config["ARG_RULZ_PORT"])
@app.route('/pusher/auth', methods=['POST']) def pusher_auth(): channel_name = request.form.get('channel_name') # Auth user based on channel name socket_id = request.form.get('socket_id') if session['user_id']: auth = pushr[channel_name].authenticate(socket_id) json_data = json.dumps(auth) return json_data return None @app.route('/logout') def logout(): session.pop('logged_in', None) logout_user() flash('You were logged out') return redirect(url_for('show_entries')) if __name__ == '__main__': import os from init import sched, track from tracker import Tracker sched.start() #start the scheduler t = Tracker() track(t) port = int(os.environ.get("PORT", 5000)) app.run(host='0.0.0.0', port=port)
def start_server(): """ 启动flask项目 """ route() # 加载路由 app.run() # 启动程序
from init import app, db import views if __name__ == '__main__': app.run(debug=True)
bugs=seriousbug, bugbit=bugbit, bugtype=bugtype) @app.route('/leaks/<int:page>', methods=['GET']) @app.route('/leaks') @login_required def FileLeakBug(page=None): bugbit, bugtype = core.GetBit() if not page: page = 1 per_page = 10 paginate = BugList.query.order_by(BugList.id.desc()).paginate( page, per_page, error_out=False) # bugs = paginate.items leak = [] leaks = BugList.query.filter() for bug in leaks: if "文件泄露" in bug.bugname: leak.append(bug) return render_template('bug-list.html', paginate=paginate, bugs=leak, bugbit=bugbit, bugtype=bugtype) if __name__ == '__main__': app.run()
header = request.form['header'] signature = request.form['signature'] body = request.form['body'] url_id = datetime.today().microsecond post = Post(header, signature, body, url_id, user_hash) db.session.add(post) db.session.commit() response = make_response(redirect(url_for('post', url_id=url_id))) response.set_cookie('user_hash', user_hash) return response @app.route('/edit/<url_id>', methods=['POST']) def edit(url_id): post = Post.query.filter_by(url_id=url_id).first() owner_hash = get_user_hash() if post.user_hash == owner_hash: post.header = request.form['header'] post.signature = request.form['signature'] post.body = request.form['body'] post.url_id = url_id post.user_hash = owner_hash db.session.commit() return redirect(url_for('post', url_id=post.url_id)) else: return render_template('post.html', post=post) if __name__ == "__main__": app.run(host='0.0.0.0')
def modifyuser(): data = request.get_json(silent=True) for i in data: if (data[i] == None): data[i] = '' username = data['username'] password = data['password'] phone = data['phone'] gender = data['gender'] age = data['age'] email = data['email'] country = data['country'] try: sql = "update user set password ='******', " + "phone='" + phone + "', " + "gender='" + gender + "', " + "age='" + age + "', " + "email='" + email + "', " + "country='" + country + "'" + " where username='******'" print("ceshi") print(sql) print("ceshi") db.session.execute(sql) print("ceshi") db.session.commit() print("ceshi") data1 = {'status': '1', 'message': '用户信息修改成功'} except (Exception): data1 = {'status': '0', 'message': '用户信息修改失败'} return data1 if __name__ == '__main__': app.run(debug=True, host='localhost', port=8900)
from init import app import routes if __name__ == "__main__": app.run(port=8080, debug=True)
def check_login(): if (not session) and (request.endpoint != 'login' and request.endpoint != 'static' and request.endpoint != 'patient.register'): return redirect(url_for('login')) @app.route('/') def logout(): session.clear() return redirect(url_for('login')) @app.route('/login', methods=['GET', 'POST']) def login(): form = LoginForm(request.form) if request.method == 'POST' and form.validate(): # pass the validation if form.role.data == '1': module = 'patient' elif form.role.data == '2': module = 'doctor' elif form.role.data == '3': module = 'clerk' return redirect(url_for('{}.index'.format(module))) return render_template('public/login.html', form=form) if __name__ == '__main__': app.run(debug=DEBUG, host='0.0.0.0', port=PORT)
from init import app as application if __name__ == "__main__": application.run()
import config from init import app if __name__ == '__main__': app.run(host='0.0.0.0', port=config.app_conf["server"]["port"], debug=False)
from init import app if __name__ == '__main__': app.run(host='0.0.0.0', port=8080, debug=False)
# from model import Record,User,db from route.view import view from route.api import api from config import * from init import app # app = Flask(__name__) # app.secret_key="qwer" # # # # 数据库 配置 # app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://'+dbUsername+':'+dbPassword+'@'+dbHost+'/'+dbName+'?charset=utf8' # # app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = Falsed # app.config['SQLALCHEMY_ECHO']=True #log显示sql语句 # app.config['JSON_AS_ASCII'] = False #支持中文 # app.config['SQLALCHEMY_POOL_RECYCLE']= 60*60 # 设置自动回收连接的时间为一小时 # database=SQLAlchemy(app)# db对象是 SQLAlchemy 类的实例 # db.create_all() # @app.before_request app.register_blueprint(api,url_prefix='/api') app.register_blueprint(view,url_prefix='/') if __name__ == '__main__': app.run(host,port=prot)
def run(host=None): """ Run development server """ if host: app.host = host app.run()
import os from init import app if __name__ == '__main__': HOST = os.environ.get('SERVER_HOST', 'localhost') try: PORT = int(os.environ.get('SERVER_PORT', '5555')) except ValueError: PORT = 5555 app.run(HOST, PORT)
from init import app from config import Config app.config['SECRET_KEY'] = 'tehe-hehe-jehe' app.config.from_object(Config) FLASK_APP = app import models, routes if __name__ == '__main__': app.run(debug='True')
from init import app, db from user.api import userBp from poi.api import poiBp app.register_blueprint(userBp, url_prefix='/user') app.register_blueprint(poiBp, url_prefix='/poi') if __name__=='__main__': app.run(debug=True, hosts='0.0.0.0')
import os import query from init import app # read environment variables + set defaults interval = os.getenv('INTERVAL', '1') print 'Starting Environment Monitor...' print 'number of records: ' + str(query.count_of_all_type('Temp')) @app.route('/') def hello_world(): return 'Hello World!' if __name__ == '__main__': app.run(host='0.0.0.0')
@app.errorhandler(MigrationErrors.MigrationError) def migration_error_handle(exception: MigrationErrors.MigrationError): # If it is one of our custom errors, log and report it to statsd statsd.increment(exception.statsd_metric) logger.error(exception.error) return flask.jsonify(exception.to_dict()), exception.http_code @app.errorhandler(HTTPException) def http_error_handler(exception: HTTPException): logger.error(f'Http exception: {repr(exception)}') return flask.jsonify({ 'code': exception.code, 'message': exception.__str__() }), exception.code @app.errorhandler(Exception) def error_handle(exception: Exception): # Log the exception and return an internal server error logger.error(f'Unexpected exception: {str(exception)}') return flask.jsonify( MigrationErrors.InternalError().to_dict()), HTTP_STATUS_INTERNAL_ERROR if __name__ == '__main__': if DEBUG: app.run('0.0.0.0', port=8000)
from init import app # config_name = "DEVELOPMENT" # create_app(config_name) if __name__ == "__main__": app.run(host="0.0.0.0", port=5002)
from flask_cors import CORS from init import app from AccountAPI import account_api from ProductAPI import product_api from init import db app.register_blueprint(account_api) app.register_blueprint(product_api) cors = CORS(app, resources={r"/*": {"origins": "*"}}) # Run Server if __name__ == '__main__': app.run(debug=True)
def main(): app.run(host=HOST, port=PORT, debug=DEBUG)
from filters import my_strftime from werkzeug.exceptions import HTTPException class AuthException(HTTPException): def __init__(self, message): super().__init__( message, Response( "You could not be authenticated. Please refresh the page.", 401, {'WWW-Authenticate': 'Basic realm="Login Required"'})) class ModelView(ModelView): def is_accessible(self): if not basic_auth.authenticate(): raise AuthException('Not authenticated.') else: return True def inaccessible_callback(self, name, **kwargs): return redirect(basic_auth.challenge()) admin.add_view(ModelView(User, 'Пользователи')) app.register_blueprint(gallery, url_prefix='') if __name__ == '__main__': app.run(host='0.0.0.0', port=5000, debug=True)
from init import app as application import routes if __name__ == '__main__': application.run(debug=True)