Example #1
0
    def send_static_files(filename):
        if not os.path.splitext(filename)[1]:
            filename += ".html"

        resp = current_app.send_static_file(filename)
        resp.mimetype = mimetypes.guess_type(filename)[0]

        return resp
Example #2
0
File: view.py Project: ktmud/david
def show(page):
    if '.' in page:
        return current_app.send_static_file(page)
    if page == 'show' or page.isdigit():
        return abort(404)
    try:
        return st('modules/pages/%s.html' % page)
    except TemplateNotFound, e:
        pass
Example #3
0
def get_random_bg_image():
    #print os.path.abspath(os.path.dirname(__file__))
    #static_dir = os.path.join(os.path.abspath(__file__), 'static')
    from random import choice
    static_dir = current_app.static_folder
    bg_image_dir= 'background_images'
    random_img_file= choice( os.listdir(static_dir+'/'+bg_image_dir) )
    print bg_image_dir+'/'+random_img_file
    return current_app.send_static_file( bg_image_dir+'/'+random_img_file)
Example #4
0
def web_html(file_name):
    if not file_name:
        file_name = 'index.html'
    if file_name != 'favicon.ico':
        file_name = 'html/' + file_name
    # 设置csrf_token到cookie中 并会给session同步存储一份
    # 读取会从session中读取
    csrf_token = generate_csrf()
    response = make_response(current_app.send_static_file(file_name))
    response.set_cookie('csrf_token', csrf_token)
    return response
Example #5
0
def profile_pic(user_id):
    """ Serve a profile picture.

        If user picture is not found, return default one.
    """
    fpath = os.path.join(current_app.config['UPLOAD_DIR'], str(user_id) + '.png')
    if  os.path.isfile(fpath):
        return send_file(fpath)

    else:
        return current_app.send_static_file('img/default_profile.png')
Example #6
0
def html_file(file_name):

    if not file_name:
        file_name = "index.html"

    if file_name != "favicon.ico":

        file_name = "html/" + file_name

    csrf_token = csrf.generate_csrf()
    response = make_response(current_app.send_static_file(file_name))

    response.set_cookie("csrf_token", csrf_token)

    return response
 def send_static(filename):
     """Sends a file from the static folder if a given file exist.
     Otherwise, tries additional folders as a fallback.
     """
     try:
         return current_app.send_static_file(filename)
     except NotFound:
         for prefix, folder in locations:
             if prefix:
                 prefix = '{}{}'.format(prefix, os.sep)
                 if filename.startswith(prefix):
                     filename = filename[len(prefix):]
             filepath = safe_join(folder, filename)
             if os.path.isfile(filepath):
                 return send_file(filepath)
         raise NotFound()
Example #8
0
def register():
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        email = request.form['email']
        if not username or not password or not email:
            return 'Input not valid.'
        try:
            user = User.objects(email=email).get()
        except Exception:
            user = User(username=username, password=bcrypt.generate_password_hash(password), email=email)
            user.save()
            flask_login.login_user(user)
            return 'Success.'
        else:
            return 'Already exists.'
    else:
        return current_app.send_static_file('register.html')
Example #9
0
def get_html_file(file_name):
    """提供html静态文件"""
    # 根据用户访问的路径提供相应的html文件
    if not file_name:
        # 如果用户访问的是/
        file_name = "index.html"

    if file_name != "favicon.ico":
        file_name = "html/" + file_name

    # 生产csrf_token字符串
    csrf_token = generate_csrf()

    # 为用户设置cookie,csrf_token
    resp = make_response(current_app.send_static_file(file_name))
    resp.set_cookie("csrf_token", csrf_token)

    return resp
Example #10
0
def login():
    if request.method == 'POST':
        email = request.form['email']
        logging.debug("{} tries to login.".format(email))
        try:
            user = User.objects(email=email).get()
            if bcrypt.check_password_hash(user.password, request.form['password']):
                flask_login.login_user(user)
                logging.debug('Logged in successfully.')
                flash('Logged in successfully.')
                return redirect(url_for('index'))
            else:
                logging.debug('Wrong password.')
                flash('Wrong password.')
                return redirect(url_for('login'))
        except Exception as e:
            logging.warning(e)
            return "User not exist."
    else:
        return current_app.send_static_file('login.html')
Example #11
0
def ogn_js():
    return current_app.send_static_file("ognlive/ogn.js")
Example #12
0
def barogram_js():
    return current_app.send_static_file("ognlive/barogram.js")
Example #13
0
def favicon():
    # send_static_file用于返回静态文件
    return current_app.send_static_file("news/favicon.ico")
Example #14
0
def _static(ds, filename):
    return current_app.send_static_file(filename=filename)
Example #15
0
def show_base_registry_full():
    return current_app.send_static_file(
            'RegistryStore/registries/en/Base.json'
    )
Example #16
0
def show_odata_service_document():
    return current_app.send_static_file('odata')
Example #17
0
def res(file_name):
    return current_app.send_static_file(file_name)
Example #18
0
def get_index():
    return current_app.send_static_file('./index.html')
Example #19
0
def get_web_logo():
    return current_app.send_static_file('news/favicon.ico')
def static_root():
    return current_app.send_static_file('index.html')
    return send_from_directory('/', 'index.html')
def hello_world():
    return current_app.send_static_file('client.html')
Example #22
0
def favicon():
    print(current_app.url_map)
    return current_app.send_static_file("news/favicon.ico")
Example #23
0
def favicon():
    """查找发送页签图标"""
    # current_app应用上下文变量,表示当前应用
    # send_static_file是flask查找指定静态文件的方法,浏览器自动请求小图标
    return current_app.send_static_file('news/favicon.ico')
Example #24
0
def hello_world():
    return current_app.send_static_file('webchat.html')
def static_root():
    return current_app.send_static_file('index.html')
    return send_from_directory('/', 'index.html')
Example #26
0
def asset(user, asset):
    # An asset is a binary in someone's garden/<user>/assets directory.
    # Currently unused.
    path = '/'.join(["garden", user, 'assets', asset])
    return current_app.send_static_file(path)
 def home(self):
     return current_app.send_static_file('index.html')
Example #28
0
def index():
    return app.send_static_file('index.html')
Example #29
0
def show_registries():
    return current_app.send_static_file('Registries.json')
Example #30
0
def getReport(fn):
    return current_app.send_static_file("pdf/" + fn)
Example #31
0
def favicon() -> Response:
    return current_app.send_static_file("images/favicon.ico")
def get_favicon():
    """Serve favicon"""
    return current_app.send_static_file('favicon.ico')
Example #33
0
def serve_static(*args, **kwargs):
    return current_app.send_static_file(*args, **kwargs)
Example #34
0
def get_fav():
    return current_app.send_static_file('ico/favicon.ico')
Example #35
0
def horizZoomControl_js():
    return current_app.send_static_file("ognlive/horizZoomControl.js")
Example #36
0
 def crossdomain():
     return current_app.send_static_file('crossdomain.xml')
Example #37
0
def util_js():
    return current_app.send_static_file("ognlive/util.js")
Example #38
0
def serveIndex():
    print("hi")
    return current_app.send_static_file("index.html")
Example #39
0
 def index():
     return current_app.send_static_file('webchat.html')
Example #40
0
def serveStatics(path):
    return current_app.send_static_file(path)
Example #41
0
def index():
    #return "Hello world!"
    #return render_template("test.html")
    return current_app.send_static_file("maltools.html")
Example #42
0
def favicon():
    """title左侧图标"""
    # return 'Users/zhangjie/Desktop/Information_29/info/static/news/favicon.ico'
    return current_app.send_static_file('news/favicon.ico')
Example #43
0
def get_terms_kt():
    print "abc"
    return current_app.send_static_file('terms/ktclub.txt')
Example #44
0
def favicon():
    return current_app.send_static_file("news/favicon.ico")
Example #45
0
def dashboard():
    return current_app.send_static_file('index.html')
Example #46
0
def hello():
    return app.send_static_file('index.html')
Example #47
0
 def get(self):
     """
     HTTP GET request
     :return: index html page
     """
     return current_app.send_static_file('index.html')
Example #48
0
def static_file(path):
    return app.send_static_file(path)
Example #49
0
def show_redfish_metadata_document():
    g.metadata = True
    return current_app.send_static_file('$metadata')
Example #50
0
def favicon():
    # 我的思路是写一个重定向, 最简单; 或者,使用模板渲染也比较简单.
    # return redirect("/static/favicon.ico")
    # 官方思路:  send_static_file 是专门用于返回 静态资源 的函数
    return current_app.send_static_file("favicon.ico")
Example #51
0
def show_base_registry():
    return current_app.send_static_file('Registries/Base.json')
Example #52
0
def index():
    return current_app.send_static_file('index.html')
Example #53
0
def show_redfishserver_registry_full():
    return current_app.send_static_file(
            'RegistryStore/registries/en/BluebirdServer.json'
    )
Example #54
0
def get_fav():
    print(__name__)
    return current_app.send_static_file('img/favicon.ico')
Example #55
0
def index():
    return current_app.send_static_file('index.html')
Example #56
0
def pict(filename):
    return current_app.send_static_file("ognlive/pict/" + filename)
Example #57
0
def robots_txt():
    """Serves the robots.txt file to manage the indexing of the site by search enginges"""
    return current_app.send_static_file('robots.txt')
Example #58
0
def favicon_gif():
    return current_app.send_static_file("ognlive/pict/favicon.gif")
Example #59
0
def embed_js():

    return current_app.send_static_file('embed.js')
Example #60
0
def web_logo():
    return current_app.send_static_file("news/favicon.ico")