在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Python/ 如何隱藏掉端口號(python flask實現(xiàn)的web服務(wù)器)

如何隱藏掉端口號(python flask實現(xiàn)的web服務(wù)器)

因為最近在做小程序想調(diào)用自己的服務(wù)器,所以已經(jīng)申請了ssl證書,并且以flask成功建成了,在小程序中不效準(zhǔn)網(wǎng)址的話可以調(diào)用了,但是端口還是不知道在哪隱藏掉?或者是反向代理轉(zhuǎn)一下?代理轉(zhuǎn)一下的話:我想接入https://wodewangzhan.cn/ 的時候轉(zhuǎn)到https://wodewangzhan.cn:5000/ 這樣的,

這是我服務(wù)器的代碼:

from flask import Flask
from flask import request
import urllib
import urllib.request
import urllib.parse
import json
from gevent.wsgi import WSGIServer


app = Flask(__name__)


@app.route('/',methods=['GET'])
def welcome():
    return 'Hello World!'
@app.route('/tu',methods=['GET'])
def welcome1():
    return 'Hello World!'
@app.route('/tu',methods=['POST'])
def zhongzhuan_url():
    # 配置您申請的APPKey
    appkey = "8080e5899b7e4534a8de2e6fb2b3363e"
    url = "http://www.tuling123.com/openapi/api"
    user_txt = request.form['info']
    user_id=request.form['userid']


    if user_txt:
        # dict1 = json.loads(a)
        # return json.dumps(dict1["data"])

        params = {
            "key": appkey,  # 您申請到的本接口專用的APPKEY
            "info": user_txt,  # 要發(fā)送給機(jī)器人的內(nèi)容,不要超過30個字符
            "dtype": "",  # 返回的數(shù)據(jù)的格式,json或xml,默認(rèn)為json
            "loc": "",  # 地點(diǎn),如北京中關(guān)村
            "lon": "",  # 經(jīng)度,東經(jīng)116.234632(小數(shù)點(diǎn)后保留6位),需要寫為116234632
            "lat": "",  # 緯度,北緯40.234632(小數(shù)點(diǎn)后保留6位),需要寫為40234632
            "userid": user_id,  # 1~32位,此userid針對您自己的每一個用戶,用于上下文的關(guān)聯(lián)

        }
        params = urllib.parse.urlencode(params)
        f = urllib.request.urlopen("%s?%s" % (url, params))
        content = f.read().decode("UTF-8")
        # res = json.loads(content)
        # print(content)
        return content

    else:
        return "你好 我的小可愛"
    # return "hello"

if __name__ == '__main__':
    # app.debug = True
    context=('../zhengshu/1_bundle.crt','../zhengshu/2_key.key')
    app.run('0.0.0.0',threaded=True,ssl_context=context)

圖片描述
外網(wǎng)在訪問我的網(wǎng)站的時候也是可以訪問的

只是完蛋的是。。。微信小程序不讓出現(xiàn)端口。。。我這個5000要怎么隱藏掉呢。。。。我曾經(jīng)試過https://www.itbulu.com/hide-f... 這個的方法,用nginx反向代理,但是這個只能將我http的網(wǎng)址轉(zhuǎn)到5000的端口,在https的時候不響應(yīng)的

location / {
#try_files $uri $uri/ =404;
proxy_pass http://127.0.0.1:5000;
}

到底要怎么辦,求指點(diǎn)。。。

回答
編輯回答
青瓷

你把nginx那里配置 https 了嗎?如果沒有配置怎么能響應(yīng) https 呢

2017年12月25日 23:54
編輯回答
怪痞

最簡單的方法:

if __name__ == '__main__':
    # app.debug = True
    context=('../zhengshu/1_bundle.crt','../zhengshu/2_key.key')
    app.run(host='0.0.0.0', post=80, threaded=True,ssl_context=context)

修改一下 app.run() 的參數(shù)即可。

2017年1月15日 02:58