-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
42 lines (33 loc) · 962 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
high level support for doing this and that.
"""
import os
import redis
from flask import Flask
from dotenv import dotenv_values
config = {
**dotenv_values(".env.shared"), # load shared development variables
**dotenv_values(".env.secret"), # load sensitive variables
**os.environ, # override loaded values with environment variables
}
print(config['url_redis'])
print(config['url_host'])
redis_cache = redis.from_url(str(config['url_redis']))
app = Flask(__name__)
@app.route('/visit/<string:user>')
def visit(user):
"""
high level support for doing this and that.
"""
redis_cache.incr(user)
return 'OK'
@app.route('/show/<string:user>')
def show(user):
"""
high level support for doing this and that.
"""
if redis_cache.exists(user):
return redis_cache.get(user)
return f'{user} is not exists'
if __name__ == '__main__':
app.run(config['url_host'], config['port'], config['debug'])