阿里云函数计算配合表格储存制作网页统计工具
本文最后更新于 1602 天前,其中的信息可能已经有所发展或是发生改变。

表格储存

import os
from tablestore import *
import time

OTS_ID = "ID"
OTS_SECRET = "SEC"
OTS_ENDPOINT = "ENDPOINT"
OTS_INSTANCE = "NAME"
#OTS_STS_TOKEN = os.getenv('OTS_TEST_STS_TOKEN')

table_name = 'visitor_count'
primary_key = [('urls', '/1/1/1')]
columns_to_get = ['numbers']

client = OTSClient(OTS_ENDPOINT, OTS_ID, OTS_SECRET, OTS_INSTANCE)

consumed, return_row, next_token = client.get_row(table_name, primary_key, columns_to_get)
if return_row != None:
    print(return_row.attribute_columns[0][1])

函数计算

from flask import Flask, request

app = Flask(__name__)

@app.route('/', methods=['GET'])
def register():
    #a = request.args.get("1")
    b = str(request.referrer)
    return b

if __name__ == '__main__':
    app.run()
上一篇
下一篇