-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
executable file
·80 lines (53 loc) · 1.29 KB
/
app.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# the above line is to avoid 'SyntaxError: Non-UTF-8 code starting with' error
'''
Created on
Course work:
@author: raja
Source:
'''
# Import necessary modules
from flask import Flask, request, jsonify, Response, abort, make_response
from flask_restful import Resource, Api
from sqlalchemy import create_engine
from json import dumps
import os
# Local import
import string_util as su
app = Flask(__name__)
api = Api(app)
'''
http://localhost:8071/
'''
@app.route("/")
def main():
result_dict = {
"result" : "welcome"
}
return make_response(jsonify(result_dict), 200)
'''
http://localhost:8071/env
'''
@app.route("/env")
def show_env():
env = int(os.environ.get('WORKER_SMTP_PORT'))
result = {
'env' : env
}
return make_response(jsonify(result), 200)
'''
http://localhost:8071/reverse
http://localhost:8071/reverse?content=hello
'''
@app.route("/reverse")
def reverse_string_api():
content = request.values.get('content')
print('c : ', content)
r_content = su.reverse_string(content)
result = {
'content' : r_content
}
return make_response(jsonify(result), 200)
if __name__ == '__main__':
app.run( host = '0.0.0.0', port = 8071, debug = True)