Ansaribinhyder commited on
Commit
a1592a0
·
1 Parent(s): 3ee8a13

Updated Flask

Browse files
Files changed (3) hide show
  1. Dockerfile +12 -1
  2. app.py +15 -0
  3. main.py +11 -17
Dockerfile CHANGED
@@ -12,4 +12,15 @@ COPY requirements.txt .
12
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
13
 
14
  COPY . .
15
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
 
 
 
 
 
 
12
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
13
 
14
  COPY . .
15
+ # CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
16
+
17
+ # Set the environment variable for Flask
18
+ ENV FLASK_APP=main.py
19
+ ENV FLASK_RUN_HOST=0.0.0.0
20
+ ENV FLASK_RUN_PORT=7860
21
+
22
+ # Expose the port Flask will run on
23
+ EXPOSE 7860
24
+
25
+ # Command to run the Flask app
26
+ CMD ["flask", "run"]
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template
2
+
3
+ app = Flask(__name__)
4
+
5
+ @app.route("/")
6
+
7
+ def index():
8
+
9
+ # Render the index.html file from the templates folder
10
+
11
+ return render_template("index.html")
12
+
13
+ if __name__ == "__main__":
14
+
15
+ app.run(debug=True)
main.py CHANGED
@@ -1,21 +1,15 @@
1
- # from fastapi import FastAPI
2
-
3
- # app = FastAPI()
4
-
5
- # @app.get("/")
6
- # def read_root():
7
- # return
8
-
9
  from flask import Flask, render_template
10
- from flask_compress import Compress
11
- import socket
 
 
12
 
13
- host_name = socket.gethostname()
14
- host_name_ipaddress = socket.gethostbyname(host_name)
15
 
16
- app = Flask(__name__)
17
- Compress(app)
 
 
 
18
 
19
- @app.route('/')
20
- def get_all_posts():
21
- return render_template("index.html")
 
 
 
 
 
 
 
 
 
1
  from flask import Flask, render_template
2
+
3
+ app = Flask(__name__)
4
+
5
+ @app.route("/")
6
 
7
+ def index():
 
8
 
9
+ # Render the index.html file from the templates folder
10
+
11
+ return render_template("index.html")
12
+
13
+ if __name__ == "__main__":
14
 
15
+ app.run(debug=True)