加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
shijiange.py 1.61 KB
一键复制 编辑 原始数据 按行查看 历史
shijiange 提交于 2019-07-10 10:10 . first commit
from flask import Blueprint
from flask import request
from flask import send_from_directory
import time,os,json
shijiange = Blueprint("shijiange", __name__)
@shijiange.route('/index')
def index():
return "Shijiange Blueprint!"
@shijiange.route('/ajaxtest')
def ajaxtest():
return "Shijiange Ajax Test Content!"
@shijiange.route('/ajaxget')
def ajaxget():
server_name = request.args.get('server_name')
server_ip = request.args.get('server_ip')
return "Server Name is: {0}, Server IP is {1}".format( server_name, server_ip )
@shijiange.route('/ajaxpost', methods=['get', 'post'])
def ajaxpost():
info = request.get_data()
info = json.loads(info)
return info['username']
@shijiange.route('/download')
def download():
curent_dir = os.path.dirname( os.path.realpath(__file__) )
return send_from_directory( curent_dir+"/static", "serverexample.xlsx", as_attachment=True )
@shijiange.route('/upload', methods=['get', 'post'])
def upload():
servers = request.files.get('servers')
ramname = int(time.time() * 1000)
print( ramname )
servers.save('/tmp/{0}'.format( ramname ))
return "Upload Success!"
@shijiange.route('/get')
def get():
print( request.args )
server_name = request.args.get("server_name")
server_ip = request.args.get("server_ip")
return "Server name is: {0}, Server IP is: {1}".format(server_name, server_ip)
@shijiange.route('/post', methods=['get', 'post'])
def post():
print( request.form )
username = request.form.get("username")
password = request.form.get("password")
return "username is: {0}, password is: {1}".format(username, password)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化