Spaces:
Running
Running
Upload main.py
Browse files
main.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request, send_file
|
2 |
+
import os, json
|
3 |
+
|
4 |
+
app = Flask(__name__)
|
5 |
+
|
6 |
+
@app.route("/")
|
7 |
+
def home():
|
8 |
+
return '''true'''
|
9 |
+
@app.route("/get_states")
|
10 |
+
def get():
|
11 |
+
states = os.listdir("states")
|
12 |
+
states_parse = []
|
13 |
+
for s in states:
|
14 |
+
states_parse.append({"id":s, "text":open(f"states/{s}/text", "r").read()})
|
15 |
+
return json.dumps(states_parse)
|
16 |
+
@app.route("/states/<ide>/image.png")
|
17 |
+
def get_image(ide):
|
18 |
+
return send_file(f"states/{ide}/image.png")
|
19 |
+
app.run()
|