Skip to content

Instantly share code, notes, and snippets.

@yudegaki
Last active November 30, 2019 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yudegaki/df7c844229c70add6df137f86f0e2c08 to your computer and use it in GitHub Desktop.
Save yudegaki/df7c844229c70add6df137f86f0e2c08 to your computer and use it in GitHub Desktop.
import json,os,base64
import urllib.request
from flask_cors import CORS,cross_origin
from flask import Flask,request,abort,jsonify
#POSTするURL設定
method = 'POST'
url = 'https://hogehoge'
headers = {'Content-Type' : 'application/json'}
#Access-Control-Allow-Originヘッダを追加
app = Flask(__name__)
cors = CORS(app)
@app.route('/',methods = ["GET","POST"])
@cross_origin()
def main():
if request.method == 'GET':
#URLエンコードで受け取った文字列をdecode
req_url = urllib.parse.unquote(request.args.get('url'))
req_get = urllib.request.Request(req_url,method = 'GET')
with urllib.request.urlopen(req_get) as response :
return response.read()
else :
今回は = '省略' + 'します'
if __name__ == '__main__':
port = int(os.getenv("PORT", 5000))
app.run(host="0.0.0.0", port=port)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment