mirror of
https://github.com/kennethreitz/httpbin.git
synced 2026-06-05 14:50:17 +00:00
basic core
This commit is contained in:
+37
-2
@@ -7,14 +7,49 @@ httpbin.core
|
||||
This module provides the core HttpBin experience.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
from flask import Flask
|
||||
|
||||
from flask import Flask, request
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
|
||||
def to_json(*args, **kwargs):
|
||||
data = dict(*args, **kwargs)
|
||||
return json.dumps(data)
|
||||
|
||||
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def hello():
|
||||
return 'Hello World!'
|
||||
return to_json(hello='world')
|
||||
|
||||
|
||||
@app.route('/headers')
|
||||
def view_headers():
|
||||
|
||||
return to_json(headers='headers')
|
||||
|
||||
|
||||
@app.route('/user-agent')
|
||||
def view_user_agent():
|
||||
return 'user agent'
|
||||
|
||||
|
||||
@app.route('/get')
|
||||
def view_get():
|
||||
return 'get'
|
||||
|
||||
|
||||
|
||||
# /headers
|
||||
# /get
|
||||
# /post
|
||||
# /put
|
||||
# /delete
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user