SHEN1017 commited on
Commit
02c1375
·
verified ·
1 Parent(s): 358eec2

Upload 5 files

Browse files
Files changed (5) hide show
  1. Dockerfile +11 -0
  2. README.md +1 -12
  3. app.py +17 -0
  4. requirements.txt +1 -0
  5. templates/index.html +13 -0
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10
2
+
3
+ WORKDIR /app
4
+
5
+ COPY . /app
6
+
7
+ RUN pip install -r requirements.txt
8
+
9
+ EXPOSE 7860
10
+
11
+ CMD ["python", "app.py"]
README.md CHANGED
@@ -1,12 +1 @@
1
- ---
2
- title: Myflask
3
- emoji: 📊
4
- colorFrom: indigo
5
- colorTo: purple
6
- sdk: docker
7
- pinned: false
8
- license: mit
9
- short_description: Myf
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ # Flask App on Hugging Face Spaces
 
 
 
 
 
 
 
 
 
 
 
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, request
2
+
3
+ app = Flask(__name__)
4
+
5
+ @app.route('/')
6
+ def index():
7
+ return render_template('index.html')
8
+
9
+ @app.route('/submit', methods=['POST'])
10
+ def submit():
11
+ text = request.form['user_input']
12
+ return f"你输入了:{text}"
13
+
14
+ if __name__ == '__main__':
15
+ app.run(host="0.0.0.0", port=7860)
16
+
17
+
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ flask
templates/index.html ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Flask 示例</title>
5
+ </head>
6
+ <body>
7
+ <h1>请输入文本:</h1>
8
+ <form action="/submit" method="post">
9
+ <input type="text" name="user_input" required>
10
+ <input type="submit" value="提交">
11
+ </form>
12
+ </body>
13
+ </html>