Skip to content

Instantly share code, notes, and snippets.

@kevinxhan
Created April 17, 2016 09:01
Show Gist options
  • Save kevinxhan/ec49c4ab31bd07cf5d8e65ee1ad85dc6 to your computer and use it in GitHub Desktop.
Save kevinxhan/ec49c4ab31bd07cf5d8e65ee1ad85dc6 to your computer and use it in GitHub Desktop.
python flask web server
# -*- coding: utf-8 -*-
import os
import sys
import argparse
import time
import threading
import json
from flask import Flask, request, abort, jsonify
from flask import render_template
from flask import send_from_directory
app = Flask(__name__, static_url_path="")
app.config.update(
DEBUG=True
)
'''
rest api intefaces
'''
@app.route("/")
def index():
if True or app_env.is_development():
return render_template('front.html')
abort(404)
@app.route('/images/<path:path>')
def images__folder(path):
root_dir = os.path.dirname(os.getcwd())
return app.send_from_directory(os.path.join(root_dir, "images", path))
'''
init app
'''
def parse_args():
parser = argparse.ArgumentParser(prog="app.py", description='run ndvr api server')
parser.add_argument('env_mode', nargs="?", default='development', help='running env mode : development, stage, production')
args = parser.parse_args()
return args
if __name__ == "__main__":
app.run(host="0.0.0.0", port=6500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment