hamza82 commited on
Commit
52f77d6
·
verified ·
1 Parent(s): 9a0c393

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -1,13 +1,18 @@
1
- from flask import Flask, jsonify
2
- from flask_cors import CORS
 
3
 
4
- app = Flask(__name__)
5
- # Enable CORS for all domains on all routes
6
- CORS(app, resources={r"/api/*": {"origins": "https://hamza82-test.hf.space"}})
7
 
8
- @app.route('/api')
9
- def hello_world():
10
- return jsonify(message="Hello from the Flask API!")
11
 
12
- if __name__ == '__main__':
13
- app.run(debug=True)
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from fastapi.staticfiles import StaticFiles
3
+ from fastapi.responses import FileResponse
4
 
5
+ app = FastAPI()
 
 
6
 
7
+ # Mount the 'static' directory to serve static files.
8
+ # Assuming your static files are in a directory named 'static'.
9
+ app.mount("/static", StaticFiles(directory="static"), name="static")
10
 
11
+ @app.get("/")
12
+ def read_root():
13
+ # Serve your static HTML file at the root.
14
+ return FileResponse('static/index.html')
15
+
16
+ @app.get("/api")
17
+ def read_api():
18
+ return {"message": "Hello from the FastAPI API!"}