Spaces:
Sleeping
Sleeping
alessandro trinca tornidor
commited on
Commit
•
0304edb
0
Parent(s):
[feat] first commit: a working gradio app built on top of fastapi
Browse files- .gitignore +97 -0
- README.md +16 -0
- app_gradio_fastapi/__init__.py +0 -0
- app_gradio_fastapi/main.py +19 -0
- requirements.txt +2 -0
.gitignore
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
venv
|
2 |
+
__pycache__
|
3 |
+
*.pyc
|
4 |
+
flagged/*
|
5 |
+
|
6 |
+
# Created by https://www.toptal.com/developers/gitignore/api/pycharm+all
|
7 |
+
# Edit at https://www.toptal.com/developers/gitignore?templates=pycharm+all
|
8 |
+
|
9 |
+
### PyCharm+all ###
|
10 |
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
11 |
+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
12 |
+
|
13 |
+
# User-specific stuff
|
14 |
+
.idea/**/workspace.xml
|
15 |
+
.idea/**/tasks.xml
|
16 |
+
.idea/**/usage.statistics.xml
|
17 |
+
.idea/**/dictionaries
|
18 |
+
.idea/**/shelf
|
19 |
+
|
20 |
+
# AWS User-specific
|
21 |
+
.idea/**/aws.xml
|
22 |
+
|
23 |
+
# Generated files
|
24 |
+
.idea/**/contentModel.xml
|
25 |
+
|
26 |
+
# Sensitive or high-churn files
|
27 |
+
.idea/**/dataSources/
|
28 |
+
.idea/**/dataSources.ids
|
29 |
+
.idea/**/dataSources.local.xml
|
30 |
+
.idea/**/sqlDataSources.xml
|
31 |
+
.idea/**/dynamic.xml
|
32 |
+
.idea/**/uiDesigner.xml
|
33 |
+
.idea/**/dbnavigator.xml
|
34 |
+
|
35 |
+
# Gradle
|
36 |
+
.idea/**/gradle.xml
|
37 |
+
.idea/**/libraries
|
38 |
+
|
39 |
+
# Gradle and Maven with auto-import
|
40 |
+
# When using Gradle or Maven with auto-import, you should exclude module files,
|
41 |
+
# since they will be recreated, and may cause churn. Uncomment if using
|
42 |
+
# auto-import.
|
43 |
+
# .idea/artifacts
|
44 |
+
# .idea/compiler.xml
|
45 |
+
# .idea/jarRepositories.xml
|
46 |
+
# .idea/modules.xml
|
47 |
+
# .idea/*.iml
|
48 |
+
# .idea/modules
|
49 |
+
# *.iml
|
50 |
+
# *.ipr
|
51 |
+
|
52 |
+
# CMake
|
53 |
+
cmake-build-*/
|
54 |
+
|
55 |
+
# Mongo Explorer plugin
|
56 |
+
.idea/**/mongoSettings.xml
|
57 |
+
|
58 |
+
# File-based project format
|
59 |
+
*.iws
|
60 |
+
|
61 |
+
# IntelliJ
|
62 |
+
out/
|
63 |
+
|
64 |
+
# mpeltonen/sbt-idea plugin
|
65 |
+
.idea_modules/
|
66 |
+
|
67 |
+
# JIRA plugin
|
68 |
+
atlassian-ide-plugin.xml
|
69 |
+
|
70 |
+
# Cursive Clojure plugin
|
71 |
+
.idea/replstate.xml
|
72 |
+
|
73 |
+
# SonarLint plugin
|
74 |
+
.idea/sonarlint/
|
75 |
+
|
76 |
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
77 |
+
com_crashlytics_export_strings.xml
|
78 |
+
crashlytics.properties
|
79 |
+
crashlytics-build.properties
|
80 |
+
fabric.properties
|
81 |
+
|
82 |
+
# Editor-based Rest Client
|
83 |
+
.idea/httpRequests
|
84 |
+
|
85 |
+
# Android studio 3.1+ serialized cache file
|
86 |
+
.idea/caches/build_file_checksums.ser
|
87 |
+
|
88 |
+
### PyCharm+all Patch ###
|
89 |
+
# Ignore everything but code style settings and run configurations
|
90 |
+
# that are supposed to be shared within teams.
|
91 |
+
|
92 |
+
.idea/*
|
93 |
+
|
94 |
+
!.idea/codeStyles
|
95 |
+
!.idea/runConfigurations
|
96 |
+
|
97 |
+
# End of https://www.toptal.com/developers/gitignore/api/pycharm+all
|
README.md
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Run the app
|
2 |
+
|
3 |
+
1. create and activate a virtual environment
|
4 |
+
2. install the dependencies
|
5 |
+
3. execute the uvicorn webserver
|
6 |
+
|
7 |
+
```bash
|
8 |
+
# create and activate a virtual environment
|
9 |
+
python3 -m venv venv
|
10 |
+
source venv/bin/activate
|
11 |
+
# install the project dependencies
|
12 |
+
python -m pip install pip --upgrade
|
13 |
+
python -m pip install -r requirements.txt
|
14 |
+
# execute the uvicorn webserver
|
15 |
+
uvicorn app_gradio_fastapi.main:app --host 0.0.0.0 --port 7860 --reload
|
16 |
+
```
|
app_gradio_fastapi/__init__.py
ADDED
File without changes
|
app_gradio_fastapi/main.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
CUSTOM_PATH = "/"
|
5 |
+
|
6 |
+
app = FastAPI()
|
7 |
+
|
8 |
+
|
9 |
+
def request_formatter(text: str) -> str:
|
10 |
+
return f"transformed {text}."
|
11 |
+
|
12 |
+
|
13 |
+
@app.get("/health")
|
14 |
+
def read_main():
|
15 |
+
return {"message": "ok"}
|
16 |
+
|
17 |
+
|
18 |
+
io = gr.Interface(request_formatter, "textbox", "textbox")
|
19 |
+
app = gr.mount_gradio_app(app, io, path=CUSTOM_PATH)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
fastapi
|