如何在PythonAnywhere上将python程序转换为Web应用程序? [英] How can I convert my python program into a web app on PythonAnywhere?

查看:78
本文介绍了如何在PythonAnywhere上将python程序转换为Web应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个python程序.出于好奇,我想在网站上实现它,以便我的朋友或任何人都可以运行它而无需直接查看代码.
这是我的程序代码的 Github链接.
我已经在PythonAnywhere上开设了一个免费帐户,并使用Flask框架添加了一个新的Web应用程序.它具有默认文件 flask_app.py :

I have made a python program. Out of curiosity, I want to implement it on a website so that my friends or anyone can run it without seeing the code directly.
Here's the Github link of my program code.
I have opened a free account on PythonAnywhere and added a new web app with the Flask framework. It has a default file flask_app.py:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello from Flask!'

我也上传了我的 .py 文件.没有使用Python Web应用程序的经验,我看过有关Flask的文章.似乎我需要将我的python代码转换为一些不同的结构.但是我不知道如何将我的 .py 文件连接和修改到flask结构.

I have uploaded my .py file too. Having no experience with Python web apps, I've looked at the articles about Flask. Seems I need to translate my python code into some different structure. But I can't figure out how to connect and modify my .py file to the flask structure.

您能告诉我该怎么做吗?还是有其他简便的方法,例如,我只需要将python程序粘贴到文件中,它将自动作为Web应用程序实现?

Can you kindly tell me how can I do so? Or is there any easy way else such that I just need to paste my python program into a file and it will be automatically implemented as a web app?

推荐答案

将这样的交互式脚本转换成网站需要进行很多工作,但有可能.PythonAnywhere博客上的本教程包含逐步指南,该指南适用于在多个页面上进行一系列输入,并产生输出,因此这可能是一个很好的起点.

There's quite a lot of work involved in turning an interactive script like that into a website, but it is possible. This tutorial on the PythonAnywhere blog has a step-by-step guide that works up to a website that takes a series of inputs across multiple pages, and produces an output, so it might be a good starting point.

这篇关于如何在PythonAnywhere上将python程序转换为Web应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆