-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUntitled.ipynb copy
133 lines (133 loc) · 3.64 KB
/
Untitled.ipynb copy
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
{
"cells": [
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"from flask import Flask\n",
"import pandas as pd\n",
"from flask import jsonify\n",
"from flask import json\n",
"from flask import request\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
" * Running on http://127.0.0.1:5559/ (Press CTRL+C to quit)\n",
"127.0.0.1 - - [29/Jan/2019 13:01:02] \"\u001b[37mGET / HTTP/1.1\u001b[0m\" 200 -\n",
"127.0.0.1 - - [29/Jan/2019 13:01:13] \"\u001b[37mPOST / HTTP/1.1\u001b[0m\" 200 -\n",
"127.0.0.1 - - [29/Jan/2019 13:01:15] \"\u001b[37mGET / HTTP/1.1\u001b[0m\" 200 -\n",
"127.0.0.1 - - [29/Jan/2019 13:01:33] \"\u001b[37mPOST / HTTP/1.1\u001b[0m\" 200 -\n",
"127.0.0.1 - - [29/Jan/2019 13:01:36] \"\u001b[37mGET / HTTP/1.1\u001b[0m\" 200 -\n",
"127.0.0.1 - - [29/Jan/2019 13:01:58] \"\u001b[37mPOST / HTTP/1.1\u001b[0m\" 200 -\n",
"127.0.0.1 - - [29/Jan/2019 13:01:58] \"\u001b[37mGET / HTTP/1.1\u001b[0m\" 200 -\n"
]
}
],
"source": [
"app=Flask(__name__)\n",
"\n",
"@app.route('/',methods=['POST','GET','PUT'])\n",
"def working():\n",
" p={'name':['Pehla','Doosra','Teesra'],'classes':['bca','cca','dca'],'rollno':[12,34,67]}\n",
" df=pd.DataFrame(p)\n",
" \n",
" return str(abc(df))\n",
"@app.route('/',methods=['POST','GET','PUT'])\n",
"def abc(df):\n",
" if request.method == 'GET':\n",
" abcd=list(df.to_dict('index').values())\n",
" return json.dumps(abcd)\n",
"\n",
" elif request.method == 'POST':\n",
" a=request.get_json()\n",
" df.append(a)\n",
" return a\n",
"app.run(port=5559)\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "invalid syntax (<ipython-input-6-c73007de2f46>, line 5)",
"output_type": "error",
"traceback": [
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-6-c73007de2f46>\"\u001b[0;36m, line \u001b[0;32m5\u001b[0m\n\u001b[0;31m .\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
]
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"@app.route('/', methods = ['GET', 'POST', 'PATCH', 'PUT', 'DELETE'])\n",
"def api_echo():\n",
" if request.method == 'GET':\n",
" return \"ECHO: GET\\n\"\n",
"\n",
" elif request.method == 'POST':\n",
" return \"ECHO: POST\\n\"\n",
"\n",
" elif request.method == 'PATCH':\n",
" return \"ECHO: PACTH\\n\"\n",
"\n",
" elif request.method == 'PUT':\n",
" return \"ECHO: PUT\\n\"\n",
"\n",
" elif request.method == 'DELETE':\n",
" return \"ECHO: DELETE\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}