forked from leancloud/python-getting-started
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
38 lines (25 loc) · 634 Bytes
/
Copy pathapp.py
File metadata and controls
38 lines (25 loc) · 634 Bytes
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
# coding: utf-8
from datetime import datetime
from flask import Flask
from flask import render_template
from flask_sockets import Sockets
from views.todos import todos_view
app = Flask(__name__)
sockets = Sockets(app)
# 动态路由
app.register_blueprint(todos_view, url_prefix='/todos')
@app.route('/')
def index():
return render_template('index.html')
@app.route('/time')
def time():
return str(datetime.now())
@app.route('/version')
def print_version():
import sys
return sys.version
@sockets.route('/echo')
def echo_socket(ws):
while True:
message = ws.receive()
ws.send(message)