如何在Django(托管在a2hosting中)中运行应用脚本python?

时间:2018-12-23 16:48:31

标签: python django python-3.x server

我只是在托管服务器上设置了我的第一个django项目(a2hosting),现在我想在Web应用程序上运行我的python脚本(计算一些内容,然后重定向到其他URL)..但我不确定如何设置它在我的django服务器上? 有人可以帮忙吗? `

一个非常简单的Flask Hello World应用程序,您可以开始使用...

从烧瓶进口烧瓶中,重定向

app = Flask(名称

@ app.route('/ set /') def hello_world(hana):     导入googlemaps     名字=哈娜     return redirect('http://mycamp.co.il/yesh/'+ name,code = 302)

@ app.route('/ hello') def hiii():     导入pymongo

def insert(myreq):
            dd={
        "hihi":"yes1yes"
    }
    myreq.insert_one(dd)
return True
client = pymongo.MongoClient("mongodb://DETAILES.@routeplan-shard-00-00-d416l.gcp.mongodb.net:27017,routeplan-shard-00-01-d416l.gcp.mongodb.net:27017,routeplan-shard-00-02-d416l.gcp.mongodb.net:27017/test?ssl=true&replicaSet=routeplan-shard-0&authSource=admin&retryWrites=true")
mydb = client['router']
myplan = mydb['planner']
mydis =  mydb['distance']
myopt =  mydb['optimal']
myreq = mydb['request']
myus = mydb['user']
q=insert(myreq)


return 'helo world %s' + q

如果名称 =='主要”:    app.run(调试= True) `

0 个答案:

没有答案